9
9
MoreHoriz ,
10
10
MoreVert ,
11
11
} from '@mui/icons-material' ;
12
- import React , { useEffect , useRef } from 'react' ;
12
+ import React from 'react' ;
13
13
14
14
const useLayerPaginationStyles = makeStyles ( {
15
15
ulVertical : {
@@ -49,8 +49,6 @@ type LayerPaginationProps = {
49
49
orientation : LayerPaginationOrientation ;
50
50
} ;
51
51
52
- const LAYER_PAGINATION_WHEEL_TIMEOUT = 500 ;
53
-
54
52
export default function LayerPagination ( props : LayerPaginationProps ) {
55
53
const StyledBadge = withStyles ( ( ) => ( {
56
54
badge : {
@@ -68,41 +66,6 @@ export default function LayerPagination(props: LayerPaginationProps) {
68
66
props . onClickPage ( page ) ;
69
67
} ,
70
68
} ) ;
71
-
72
- const pageRefs : Map < number , React . RefObject < HTMLDivElement > > = new Map ( ) ;
73
- for ( const item of items ) {
74
- if ( item . type === 'page' && item . page !== null ) {
75
- pageRefs . set ( item . page , useRef < HTMLDivElement > ( null ) ) ;
76
- }
77
- }
78
-
79
- useEffect ( ( ) => {
80
- let processing = false ;
81
- const handleWheel = ( event : WheelEvent ) => {
82
- event . preventDefault ( ) ;
83
- if ( processing ) {
84
- return ;
85
- }
86
- processing = true ;
87
- if ( event . deltaY < 0 ) {
88
- props . onClickPage ( Math . min ( props . page ! + 1 , props . count ) ) ;
89
- } else if ( event . deltaY > 0 ) {
90
- props . onClickPage ( Math . max ( 1 , props . page ! - 1 ) ) ;
91
- }
92
- setTimeout ( ( ) => {
93
- processing = false ;
94
- } , LAYER_PAGINATION_WHEEL_TIMEOUT ) ;
95
- } ;
96
- for ( const ref of pageRefs . values ( ) ) {
97
- ref . current ?. addEventListener ( 'wheel' , handleWheel , { passive : false } ) ;
98
- }
99
- return ( ) => {
100
- for ( const ref of pageRefs . values ( ) ) {
101
- ref . current ?. removeEventListener ( 'wheel' , handleWheel ) ;
102
- }
103
- } ;
104
- } ) ;
105
-
106
69
return (
107
70
< nav >
108
71
< ul
@@ -127,11 +90,10 @@ export default function LayerPagination(props: LayerPaginationProps) {
127
90
label = { page - 1 }
128
91
color = { selected ? 'primary' : undefined }
129
92
clickable = { ! selected }
130
- onClick = { ( ) : void => {
93
+ onClick = { ( ) => {
131
94
props . onClickPage ( page ) ;
132
95
} }
133
96
className = { selected ? '' : classes . unselected }
134
- ref = { pageRefs . get ( page ) ! }
135
97
/>
136
98
</ StyledBadge >
137
99
) ;
0 commit comments