Files
kiss-translator/src/libs/touch.js

13 lines
303 B
JavaScript
Raw Normal View History

2023-11-11 16:59:38 +08:00
export function touchTapListener(fn, touchsLength) {
2023-11-10 18:00:34 +08:00
const handleTouchend = (e) => {
2023-11-11 16:59:38 +08:00
if (e.touches.length === touchsLength) {
2023-11-10 18:00:34 +08:00
fn();
}
};
2023-11-11 16:59:38 +08:00
document.addEventListener("touchstart", handleTouchend);
2023-11-10 18:00:34 +08:00
return () => {
2023-11-11 16:59:38 +08:00
document.removeEventListener("touchstart", handleTouchend);
2023-11-10 18:00:34 +08:00
};
}