diff --git a/src/actions/pausable/pausable.js b/src/actions/pausable/pausable.js index 95207c6..fdfd5d2 100644 --- a/src/actions/pausable/pausable.js +++ b/src/actions/pausable/pausable.js @@ -1,4 +1,7 @@ -import { createDispatcher, getIsTouchable } from '../../utils/event' +import { + createDispatcher, + getIsTouchable, +} from '../../utils/event' import { focusable } from '../focusable' import { tappable } from '../tappable' diff --git a/src/actions/swipeable/swipeable.js b/src/actions/swipeable/swipeable.js index 5800eeb..d4f8bf8 100644 --- a/src/actions/swipeable/swipeable.js +++ b/src/actions/swipeable/swipeable.js @@ -37,7 +37,7 @@ export function swipeable(node, { thresholdProvider }) { return swipeDurationMs >= SWIPE_MIN_DURATION_MS && Math.abs(moved) >= SWIPE_MIN_DISTANCE_PX } - function handleMousedown(event) { + function handleDown(event) { swipeStartedAt = Date.now() moved = 0 isTouching = true @@ -45,11 +45,11 @@ export function swipeable(node, { thresholdProvider }) { x = coords.x y = coords.y dispatch('swipeStart', { x, y }) - addMoveEventListener(window, handleMousemove) - addEndEventListener(window, handleMouseup) + addMoveEventListener(window, handleMove) + addEndEventListener(window, handleUp) } - function handleMousemove(event) { + function handleMove(event) { if (!isTouching) return const coords = getCoords(event) const dx = coords.x - x @@ -64,14 +64,14 @@ export function swipeable(node, { thresholdProvider }) { moved += dx if (Math.abs(moved) > thresholdProvider()) { dispatch('swipeThresholdReached', { direction: moved > 0 ? PREV : NEXT }) - removeEndEventListener(window, handleMouseup) - removeMoveEventListener(window, handleMousemove) + removeEndEventListener(window, handleUp) + removeMoveEventListener(window, handleMove) } } - function handleMouseup(event) { - removeEndEventListener(window, handleMouseup) - removeMoveEventListener(window, handleMousemove) + function handleUp(event) { + removeEndEventListener(window, handleUp) + removeMoveEventListener(window, handleMove) isTouching = false @@ -83,10 +83,10 @@ export function swipeable(node, { thresholdProvider }) { dispatch('swipeEnd', { x: coords.x, y: coords.y }) } - addStartEventListener(node, handleMousedown) + addStartEventListener(node, handleDown) return { destroy() { - removeStartEventListener(node, handleMousedown) + removeStartEventListener(node, handleDown) }, } } diff --git a/src/utils/math.js b/src/utils/math.js index e70bec2..3ecae8f 100644 --- a/src/utils/math.js +++ b/src/utils/math.js @@ -1,6 +1,6 @@ export const getDistance = (p1, p2) => { - const x = p2.x - p1.x; - const y = p2.y - p1.y; + const xDist = p2.x - p1.x; + const yDist = p2.y - p1.y; - return Math.sqrt((x * x) + (y * y)); + return Math.sqrt((xDist * xDist) + (yDist * yDist)); }