Skip to content

Commit

Permalink
Version 1.0.3
Browse files Browse the repository at this point in the history
- Fix bug with ref
  • Loading branch information
rajatkantinandi committed Jan 1, 2020
1 parent 52c7e73 commit 6603ef7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "use-swipe-hook",
"version": "1.0.1",
"version": "1.0.3",
"description": "A simple and easy to use tiny library that provides useSwipe hook to use with React that enables swipe gestures for touch screens",
"main": "lib/index.umd.js",
"browser": "lib/index.umd.js",
Expand Down
8 changes: 4 additions & 4 deletions src/useSwipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ const useSwipe = ({ ref, thresholdPX = 5 }) => {
}, [x2, y2, thresholdPX]);

React.useEffect(() => {
const currentElement = elemRef.current;
const currentElement = ref.current;
if (currentElement) {
elemRef.current.addEventListener('touchstart', handleTouchStart);
elemRef.current.addEventListener('touchend', handleTouchEnd);
currentElement.addEventListener('touchstart', handleTouchStart);
currentElement.addEventListener('touchend', handleTouchEnd);
}

return () => {
Expand All @@ -29,7 +29,7 @@ const useSwipe = ({ ref, thresholdPX = 5 }) => {
currentElement.removeEventListener('touchend', handleTouchEnd);
}
}
}, [elemRef]);
}, [ref]);

function handleTouchStart(event) {
setX1(event.changedTouches[0].clientX);
Expand Down

0 comments on commit 6603ef7

Please sign in to comment.