@@ -7,14 +7,69 @@ import {
7
7
} from "recyclerlistview" ;
8
8
import { DefaultJSItemAnimator } from "recyclerlistview/dist/reactnative/platform/reactnative/itemanimators/defaultjsanimator/DefaultJSItemAnimator" ;
9
9
10
+ /**
11
+ * Checks if a wheel event should be handled by a nested scrollable element.
12
+ */
13
+ const shouldNestedElementHandleScroll = (
14
+ event : globalThis . WheelEvent
15
+ ) : boolean => {
16
+ const targetNode = event . target ;
17
+ if ( ! ( targetNode instanceof HTMLElement ) ) {
18
+ return false ;
19
+ }
20
+
21
+ let target : HTMLElement | null = targetNode ;
22
+ const currentTarget = event . currentTarget as HTMLElement ;
23
+
24
+ while ( target && target !== currentTarget ) {
25
+ const style = window . getComputedStyle ( target ) ;
26
+ const overflowY = style . overflowY ;
27
+ const overflowX = style . overflowX ;
28
+
29
+ const isScrollableY =
30
+ overflowY === "auto" || overflowY === "scroll" || overflowY === "overlay" ;
31
+ const isScrollableX =
32
+ overflowX === "auto" || overflowX === "scroll" || overflowX === "overlay" ;
33
+
34
+ // Check if element should handle vertical scroll
35
+ if ( isScrollableY && target . scrollHeight > target . clientHeight ) {
36
+ if (
37
+ ( event . deltaY > 0 &&
38
+ target . scrollTop < target . scrollHeight - target . clientHeight ) ||
39
+ ( event . deltaY < 0 && target . scrollTop > 0 )
40
+ ) {
41
+ return true ;
42
+ }
43
+ }
44
+
45
+ // Check if element should handle horizontal scroll
46
+ if ( isScrollableX && target . scrollWidth > target . clientWidth ) {
47
+ if (
48
+ ( event . deltaX > 0 &&
49
+ target . scrollLeft < target . scrollWidth - target . clientWidth ) ||
50
+ ( event . deltaX < 0 && target . scrollLeft > 0 )
51
+ ) {
52
+ return true ;
53
+ }
54
+ }
55
+
56
+ target = target . parentElement ;
57
+ }
58
+
59
+ return false ;
60
+ } ;
61
+
10
62
const createInvertedWheelEventHandler = ( type : "horizontal" | "vertical" ) => {
11
63
return ( event : globalThis . WheelEvent ) => {
12
- const node = event . currentTarget as HTMLElement ;
64
+ if ( shouldNestedElementHandleScroll ( event ) ) {
65
+ return ;
66
+ }
13
67
68
+ const currentTarget = event . currentTarget as HTMLElement ;
14
69
const deltaX = type === "horizontal" ? - event . deltaX : event . deltaX ;
15
70
const deltaY = type === "vertical" ? - event . deltaY : event . deltaY ;
16
71
17
- node . scrollBy ( {
72
+ currentTarget . scrollBy ( {
18
73
top : deltaY ,
19
74
left : deltaX ,
20
75
behavior : "auto" ,
0 commit comments