Skip to content

Commit d34102f

Browse files
authored
Merge pull request #863 from remap-keys/revert-861-support-wheel-event-on-layer-paging-ui
Revert "Support a wheel event to change the page on a layer paging UI."
2 parents 7e7ef52 + 49a9563 commit d34102f

File tree

1 file changed

+2
-40
lines changed

1 file changed

+2
-40
lines changed

src/components/common/layer/LayerPagination.tsx

+2-40
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
MoreHoriz,
1010
MoreVert,
1111
} from '@mui/icons-material';
12-
import React, { useEffect, useRef } from 'react';
12+
import React from 'react';
1313

1414
const useLayerPaginationStyles = makeStyles({
1515
ulVertical: {
@@ -49,8 +49,6 @@ type LayerPaginationProps = {
4949
orientation: LayerPaginationOrientation;
5050
};
5151

52-
const LAYER_PAGINATION_WHEEL_TIMEOUT = 500;
53-
5452
export default function LayerPagination(props: LayerPaginationProps) {
5553
const StyledBadge = withStyles(() => ({
5654
badge: {
@@ -68,41 +66,6 @@ export default function LayerPagination(props: LayerPaginationProps) {
6866
props.onClickPage(page);
6967
},
7068
});
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-
10669
return (
10770
<nav>
10871
<ul
@@ -127,11 +90,10 @@ export default function LayerPagination(props: LayerPaginationProps) {
12790
label={page - 1}
12891
color={selected ? 'primary' : undefined}
12992
clickable={!selected}
130-
onClick={(): void => {
93+
onClick={() => {
13194
props.onClickPage(page);
13295
}}
13396
className={selected ? '' : classes.unselected}
134-
ref={pageRefs.get(page)!}
13597
/>
13698
</StyledBadge>
13799
);

0 commit comments

Comments
 (0)