-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedition-labels.js
More file actions
37 lines (30 loc) · 946 Bytes
/
Copy pathedition-labels.js
File metadata and controls
37 lines (30 loc) · 946 Bytes
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
35
36
37
/*
Reveals a team photo's name labels (see .edition-labels in
edition.css) on long-press. Desktop gets a plain CSS :hover for
this; touch devices have no hover state at all, so pressing and
holding is the equivalent here — release, or dragging off the
photo, hides the labels again.
*/
const LONG_PRESS_DURATION = 400;
const frames = document.querySelectorAll(".image-frame");
frames.forEach(
(frame) => {
let pressTimer = null;
const reveal = () => {
frame.classList.add("is-revealed");
};
const cancel = () => {
window.clearTimeout(pressTimer);
frame.classList.remove("is-revealed");
};
frame.addEventListener(
"pointerdown",
() => {
pressTimer = window.setTimeout(reveal, LONG_PRESS_DURATION);
}
);
frame.addEventListener("pointerup", cancel);
frame.addEventListener("pointercancel", cancel);
frame.addEventListener("pointerleave", cancel);
}
);