aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils.mjs
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-10-04 13:38:08 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-10-04 15:11:28 +0800
commitdbd3b03ec842c446488135853ed380f5a75adb27 (patch)
tree00fa406566361a308808add3cdc445ed892e81ec /src/utils.mjs
parentec23491d3a39f9f9201449f14a536b7540a8c281 (diff)
docs: add jsdoc
Diffstat (limited to 'src/utils.mjs')
-rw-r--r--src/utils.mjs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/utils.mjs b/src/utils.mjs
index c9a2457..ffd8978 100644
--- a/src/utils.mjs
+++ b/src/utils.mjs
@@ -88,6 +88,11 @@ export function throttle (func, delay) {
88 } 88 }
89} 89}
90 90
91/**
92 * shiftByWindow. make sure HTMLElement inside viewport
93 *
94 * @param {HTMLElement} element
95 */
91export const shiftByWindow = element => { 96export const shiftByWindow = element => {
92 const rect = element.getBoundingClientRect() 97 const rect = element.getBoundingClientRect()
93 const offsetX = window.innerWidth - rect.left - rect.width 98 const offsetX = window.innerWidth - rect.left - rect.width