aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-10-06 15:29:23 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-10-06 19:52:04 +0800
commit2f82762ace33a0986c1ec3fc72da83113810dae9 (patch)
tree6c109631c46303e4d351ca70c351d6fc7e87ef12
parent9596931d2736d14726eeaa2d518cb732d628d904 (diff)
fix: logic about checking element inside
-rw-r--r--src/utils.mjs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/utils.mjs b/src/utils.mjs
index ddd3034..dba023a 100644
--- a/src/utils.mjs
+++ b/src/utils.mjs
@@ -124,12 +124,12 @@ export const insideWindow = element => {
124export const insideParent = (childElement, parentElement) => { 124export const insideParent = (childElement, parentElement) => {
125 const childRect = childElement.getBoundingClientRect() 125 const childRect = childElement.getBoundingClientRect()
126 const parentRect = parentElement.getBoundingClientRect() 126 const parentRect = parentElement.getBoundingClientRect()
127 const offset = 20 127 const offset = 10
128 128
129 return ( 129 return (
130 childRect.left > parentRect.left + offset && 130 childRect.left < parentRect.right - offset &&
131 childRect.right < parentRect.right - offset && 131 childRect.right > parentRect.left + offset &&
132 childRect.top > parentRect.top + offset && 132 childRect.top < parentRect.bottom - offset &&
133 childRect.bottom < parentRect.bottom - offset 133 childRect.bottom > parentRect.top + offset
134 ) 134 )
135} 135}