diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-06 15:29:23 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-06 19:52:04 +0800 |
commit | 2f82762ace33a0986c1ec3fc72da83113810dae9 (patch) | |
tree | 6c109631c46303e4d351ca70c351d6fc7e87ef12 /src | |
parent | 9596931d2736d14726eeaa2d518cb732d628d904 (diff) |
fix: logic about checking element inside
Diffstat (limited to 'src')
-rw-r--r-- | src/utils.mjs | 10 |
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 => { | |||
124 | export const insideParent = (childElement, parentElement) => { | 124 | export 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 | } |