Skip to content

Commit

Permalink
Merge pull request #64 from andycoles/patch-11
Browse files Browse the repository at this point in the history
iOS safari touchmove event fix
  • Loading branch information
VikLiegostaiev authored Oct 31, 2020
2 parents 8bc83d8 + 4b365ae commit 9c40f62
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const ReactPageScroller = ({
DEFAULT_COMPONENTS_TO_RENDER_LENGTH,
);
const prevComponentIndex = usePrevious(componentIndex);
const scrollContainer = useRef(null);
const pageContainer = useRef(null);
const lastScrolledElement = useRef(null);

Expand Down Expand Up @@ -238,11 +239,11 @@ const ReactPageScroller = ({
);

useEffect(() => {
pageContainer.current.addEventListener(Events.TOUCHMOVE, touchMove);
pageContainer.current.addEventListener(Events.KEYDOWN, keyPress);
scrollContainer.current.addEventListener(Events.TOUCHMOVE, touchMove);
scrollContainer.current.addEventListener(Events.KEYDOWN, keyPress);
return () => {
pageContainer.current.removeEventListener(Events.TOUCHMOVE, touchMove);
pageContainer.current.removeEventListener(Events.KEYDOWN, keyPress);
scrollContainer.current.removeEventListener(Events.TOUCHMOVE, touchMove);
scrollContainer.current.removeEventListener(Events.KEYDOWN, keyPress);
};
}, [touchMove, keyPress]);

Expand Down Expand Up @@ -327,6 +328,7 @@ const ReactPageScroller = ({

return (
<div
ref={scrollContainer}
style={{
height: containerHeight,
width: containerWidth,
Expand Down

0 comments on commit 9c40f62

Please sign in to comment.