#49 : Dispatch and handle swipe failed

This commit is contained in:
Vadim
2021-08-06 23:32:41 +03:00
parent 2ac5a9e190
commit 8243883612
2 changed files with 18 additions and 8 deletions

View File

@@ -70,13 +70,17 @@ export function swipeable(node, { thresholdProvider }) {
}
function handleMouseup(event) {
isTouching = false
if (!isValidSwipe()) return
const coords = getCoords(event)
dispatch('end', { x: coords.x, y: coords.y })
removeEndEventListener(window, handleMouseup)
removeMoveEventListener(window, handleMousemove)
isTouching = false
if (!isValidSwipe()) {
dispatch('swipeFailed')
return
}
const coords = getCoords(event)
dispatch('end', { x: coords.x, y: coords.y })
}
addStartEventListener(node, handleMousedown)