13 lines
303 B
JavaScript
13 lines
303 B
JavaScript
export function touchTapListener(fn, touchsLength) {
|
|
const handleTouchend = (e) => {
|
|
if (e.touches.length === touchsLength) {
|
|
fn();
|
|
}
|
|
};
|
|
|
|
document.addEventListener("touchstart", handleTouchend);
|
|
return () => {
|
|
document.removeEventListener("touchstart", handleTouchend);
|
|
};
|
|
}
|