-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (28 loc) · 877 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import snip from "./src/snip.js";
window.snip = snip;
export default {
loadByLongPress(payload){
const timeout = payload.timeout || 5000;
let timer;
let timeLongPress = timeout;
const handleTap = function (event) {
if (payload.onlyFromTags && !payload.onlyFromTags.includes(event.target.nodeName)) {
return;
}
timer = setTimeout(() => {
if (timeLongPress === timeout) {
timeLongPress = 500;
}
//alert("start mysnip");
snip(payload);
}, timeLongPress);
};
const handleEnd = function () {
clearTimeout(timer);
};
document.body.addEventListener("touchstart", handleTap);
document.body.addEventListener("mousedown", handleTap);
document.body.addEventListener("touchend", handleEnd);
document.body.addEventListener("mouseup", handleEnd);
}
}