Skip to content

Commit

Permalink
fix: touchend event not fired when long press selection
Browse files Browse the repository at this point in the history
Change-Id: Icaad4860dd895b6107cb4c6010b3e72b2b012399
  • Loading branch information
hazhihui committed Oct 8, 2021
1 parent 63b3b39 commit 748ca44
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/hooks/useMobileTouchMove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ export default function useMobileTouchMove(
const onTouchStart = (e: TouchEvent) => {
cleanUpEvents();

if (e.touches.length === 1) {
elementRef.current = e.target as HTMLElement;
elementRef.current.addEventListener('touchend', onTouchEnd);
}

if (e.touches.length === 1 && !touchedRef.current) {
touchedRef.current = true;
touchYRef.current = Math.ceil(e.touches[0].pageY);

elementRef.current = e.target as HTMLElement;
elementRef.current.addEventListener('touchmove', onTouchMove);
elementRef.current.addEventListener('touchend', onTouchEnd);
}
};

Expand Down

0 comments on commit 748ca44

Please sign in to comment.