#49 : Update swipe event names

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

View File

@@ -44,7 +44,7 @@ export function swipeable(node, { thresholdProvider }) {
const coords = getCoords(event)
x = coords.x
y = coords.y
dispatch('start', { x, y })
dispatch('swipeStart', { x, y })
addMoveEventListener(window, handleMousemove)
addEndEventListener(window, handleMouseup)
}
@@ -56,14 +56,14 @@ export function swipeable(node, { thresholdProvider }) {
const dy = coords.y - y
x = coords.x
y = coords.y
dispatch('move', { x, y, dx, dy })
dispatch('swipeMove', { x, y, dx, dy })
if (dx !== 0 && Math.sign(dx) !== Math.sign(moved)) {
moved = 0
}
moved += dx
if (Math.abs(moved) > thresholdProvider()) {
dispatch('threshold', { direction: moved > 0 ? PREV : NEXT })
dispatch('swipeThresholdReached', { direction: moved > 0 ? PREV : NEXT })
removeEndEventListener(window, handleMouseup)
removeMoveEventListener(window, handleMousemove)
}
@@ -80,7 +80,7 @@ export function swipeable(node, { thresholdProvider }) {
return
}
const coords = getCoords(event)
dispatch('end', { x: coords.x, y: coords.y })
dispatch('swipeEnd', { x: coords.x, y: coords.y })
}
addStartEventListener(node, handleMousedown)