-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
27 lines (22 loc) · 866 Bytes
/
Copy pathscript.js
File metadata and controls
27 lines (22 loc) · 866 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
// Reveals the masked voucher code, character by character, to depict
// the moment a recipient shares their pickup code with an agent. The
// REDEEMED stamp (pure CSS, see styles.css) fires shortly after.
const CODE = '482913';
const codeEl = document.getElementById('voucher-code');
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
function revealCode() {
if (prefersReducedMotion) {
codeEl.textContent = CODE;
return;
}
let revealed = 0;
const interval = setInterval(() => {
revealed += 1;
const shown = CODE.slice(0, revealed);
const hidden = '•'.repeat(CODE.length - revealed);
codeEl.textContent = shown + hidden;
if (revealed >= CODE.length) clearInterval(interval);
}, 220);
}
// Start shortly after load so the eye lands on the card first.
setTimeout(revealCode, 500);