diff options
Diffstat (limited to 'src/utils.mjs')
-rw-r--r-- | src/utils.mjs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/utils.mjs b/src/utils.mjs index d9ed2d7..c9a2457 100644 --- a/src/utils.mjs +++ b/src/utils.mjs | |||
@@ -87,3 +87,10 @@ export function throttle (func, delay) { | |||
87 | return func.call(context, ...args) | 87 | return func.call(context, ...args) |
88 | } | 88 | } |
89 | } | 89 | } |
90 | |||
91 | export const shiftByWindow = element => { | ||
92 | const rect = element.getBoundingClientRect() | ||
93 | const offsetX = window.innerWidth - rect.left - rect.width | ||
94 | const offsetY = window.innerHeight - rect.top - rect.height | ||
95 | element.style.transform = `translate(${offsetX < 0 ? offsetX : 0}px, ${offsetY < 0 ? offsetY : 0}px)` | ||
96 | } | ||