aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.mjs')
-rw-r--r--src/utils.mjs7
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
91export 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}