Skip to content

Commit

Permalink
fix: useLongPress hook linting fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
xobotyi authored and a.zinoviev committed Sep 4, 2020
1 parent 22211d9 commit 9f3cc3d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/useLongPress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ interface Options {
delay?: number;
}

const isTouchEvent = (event: Event): event is TouchEvent => {
return 'touches' in event;
const isTouchEvent = (ev: Event): ev is TouchEvent => {
return 'touches' in ev;
};

const preventDefault = (event: Event) => {
if (!isTouchEvent(event)) return;
const preventDefault = (ev: Event) => {
if (!isTouchEvent(ev)) return;

if (event.touches.length < 2 && event.preventDefault) {
event.preventDefault();
if (ev.touches.length < 2 && ev.preventDefault) {
ev.preventDefault();
}
};

Expand All @@ -33,7 +33,7 @@ const useLongPress = (
}
timeout.current = setTimeout(() => callback(event), delay);
},
[callback, delay]
[callback, delay, isPreventDefault]
);

const clear = useCallback(() => {
Expand All @@ -43,7 +43,7 @@ const useLongPress = (
if (isPreventDefault && target.current) {
target.current.removeEventListener('touchend', preventDefault);
}
}, []);
}, [isPreventDefault]);

return {
onMouseDown: (e: any) => start(e),
Expand Down

0 comments on commit 9f3cc3d

Please sign in to comment.