react-use-gestures
Advanced tools
Comparing version 0.1.0 to 0.1.1
14
index.js
@@ -6,5 +6,8 @@ export function useGestures({ | ||
}) { | ||
let lastMove; | ||
function handleTouchStart(e) { | ||
window.addEventListener('touchmove', handleTouchMove); | ||
window.addEventListener('touchend', handleTouchEnd); | ||
window.addEventListener('touchcancel', handleTouchEnd); | ||
handleTake(e.touches[0]); | ||
@@ -20,3 +23,10 @@ } | ||
window.removeEventListener('touchend', handleTouchEnd); | ||
handleRelease(e.touches[0]); | ||
window.removeEventListener('touchcancel', handleTouchEnd); | ||
// weird chrome bug where touchend event is called without the touch data | ||
// so we patch with the last touch coordinate we have | ||
if (e.touches.length === 0) { | ||
handleRelease(lastMove); | ||
} else { | ||
handleRelease(e.touches[0]); | ||
} | ||
} | ||
@@ -46,2 +56,3 @@ | ||
initialY = pageY; | ||
lastMove = { pageX, pageY }; | ||
onTake({ pageX, initialX, pageY, initialY }); | ||
@@ -52,2 +63,3 @@ } | ||
const deltaY = pageY - initialY; | ||
lastMove = { pageX, pageY }; | ||
onMove({ pageX, initialX, deltaX, pageY, initialY, deltaY }); | ||
@@ -54,0 +66,0 @@ } |
{ | ||
"name": "react-use-gestures", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "An utility function to use with React hooks that plays well with https://github.com/drcmda/react-spring 's useSpring()", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3945
62