File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
4
4
import styles from './SwipeableList.css' ;
5
5
6
- const SwipeableList = ( { children, threshold } ) => {
6
+ const SwipeableList = ( { children, scrollElement , threshold } ) => {
7
7
const [ blockSwipe , setBlockSwipe ] = useState ( false ) ;
8
8
9
9
useEffect ( ( ) => {
@@ -16,6 +16,18 @@ const SwipeableList = ({ children, threshold }) => {
16
16
} ;
17
17
} , [ ] ) ;
18
18
19
+ useEffect ( ( ) => {
20
+ if ( scrollElement ) {
21
+ scrollElement . addEventListener ( 'scroll' , handleScroll ) ;
22
+ }
23
+
24
+ return ( ) => {
25
+ if ( scrollElement ) {
26
+ scrollElement . removeEventListener ( 'scroll' , handleScroll ) ;
27
+ }
28
+ } ;
29
+ } , [ scrollElement ] ) ;
30
+
19
31
const handleDragStart = ( ) => setBlockSwipe ( false ) ;
20
32
21
33
const handleDragEnd = ( ) => setBlockSwipe ( false ) ;
@@ -39,6 +51,7 @@ const SwipeableList = ({ children, threshold }) => {
39
51
40
52
SwipeableList . propTypes = {
41
53
children : PropTypes . node ,
54
+ scrollElement : PropTypes . instanceOf ( EventTarget ) ,
42
55
threshold : PropTypes . number
43
56
} ;
44
57
You can’t perform that action at this time.
0 commit comments