Browse Source

Fix ripple again

master
morethanwords 4 years ago
parent
commit
cd418286b7
  1. 9
      src/components/ripple.ts

9
src/components/ripple.ts

@ -56,6 +56,7 @@ export function ripple(elem: HTMLElement, callback: (id: number) => Promise<bool
} }
handler = null; handler = null;
touchStartFired = false;
}; };
//}); //});
@ -126,6 +127,7 @@ export function ripple(elem: HTMLElement, callback: (id: number) => Promise<bool
//}); //});
}; };
// TODO: rename this variable
let touchStartFired = false; let touchStartFired = false;
if(touchSupport) { if(touchSupport) {
let touchEnd = () => { let touchEnd = () => {
@ -134,7 +136,10 @@ export function ripple(elem: HTMLElement, callback: (id: number) => Promise<bool
elem.addEventListener('touchstart', (e) => { elem.addEventListener('touchstart', (e) => {
//console.log('ripple touchstart', e); //console.log('ripple touchstart', e);
if(e.touches.length > 1 || ((e.target as HTMLElement).tagName == 'BUTTON' && e.target != elem) || findUpClassName(e.target as HTMLElement, 'c-ripple') != r) { if(e.touches.length > 1
|| touchStartFired
|| ((e.target as HTMLElement).tagName == 'BUTTON' && e.target != elem)
|| findUpClassName(e.target as HTMLElement, 'c-ripple') != r) {
return; return;
} }
@ -149,7 +154,7 @@ export function ripple(elem: HTMLElement, callback: (id: number) => Promise<bool
e.cancelBubble = true; e.cancelBubble = true;
e.stopPropagation(); e.stopPropagation();
touchEnd(); touchEnd();
window.removeEventListener('touchend', touchEnd); elem.removeEventListener('touchend', touchEnd);
}, {once: true}); }, {once: true});
}, {passive: true}); }, {passive: true});
} else { } else {

Loading…
Cancel
Save