Skip to content

Commit

Permalink
fix(touch-ripple): remove ripple wave on contextmenu
Browse files Browse the repository at this point in the history
  • Loading branch information
nolimits4web committed Aug 16, 2022
1 parent 7abac56 commit 9aad8d5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/react/shared/use-touch-ripple.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ export const useTouchRipple = (elRef, needsTouchRipple, eventsElRef) => {
el.addEventListener('pointerdown', onPointerDown);
el.addEventListener('pointermove', onPointerMove);
el.addEventListener('pointerup', onPointerUp);
el.addEventListener('pointercancel', onPointerUp);
el.addEventListener('contextmenu', onPointerUp);
};
const detachEvents = () => {
const el = eventsElRef.current;
el.removeEventListener('pointerdown', onPointerDown);
el.removeEventListener('pointermove', onPointerMove);
el.removeEventListener('pointerup', onPointerUp);
el.removeEventListener('pointercancel', onPointerUp);
el.removeEventListener('contextmenu', onPointerUp);
};
const onMounted = () => {
if (!eventsElRef || !eventsElRef.current || !needsTouchRipple) return;
Expand Down
4 changes: 4 additions & 0 deletions src/svelte/shared/use-touch-ripple.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ export const useTouchRipple = (el, touchRipple, eventsEl) => {
eventsEl.current.addEventListener('pointerdown', onPointerDown);
eventsEl.current.addEventListener('pointermove', onPointerMove);
eventsEl.current.addEventListener('pointerup', onPointerUp);
eventsEl.current.addEventListener('pointercancel', onPointerUp);
eventsEl.current.addEventListener('contextmenu', onPointerUp);
};
const detachEvents = () => {
if (!eventsEl || !eventsEl.current || !eventsEl.current.addEventListener)
return;
eventsEl.current.removeEventListener('pointerdown', onPointerDown);
eventsEl.current.removeEventListener('pointermove', onPointerMove);
eventsEl.current.removeEventListener('pointerup', onPointerUp);
eventsEl.current.removeEventListener('pointercancel', onPointerUp);
eventsEl.current.removeEventListener('contextmenu', onPointerUp);
};

onMount(() => {
Expand Down
4 changes: 4 additions & 0 deletions src/vue/shared/use-touch-ripple.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,17 @@ export const useTouchRipple = (
el.addEventListener('pointerdown', onPointerDown);
el.addEventListener('pointermove', onPointerMove);
el.addEventListener('pointerup', onPointerUp);
el.addEventListener('pointercancel', onPointerUp);
el.addEventListener('contextmenu', onPointerUp);
};
const detachEvents = () => {
eventsAttached = false;
const el = getEl(eventsElRef);
el.removeEventListener('pointerdown', onPointerDown);
el.removeEventListener('pointermove', onPointerMove);
el.removeEventListener('pointerup', onPointerUp);
el.removeEventListener('pointercancel', onPointerUp);
el.removeEventListener('contextmenu', onPointerUp);
};

watch(
Expand Down

0 comments on commit 9aad8d5

Please sign in to comment.