-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
64 lines (50 loc) · 1.99 KB
/
Copy pathscript.js
File metadata and controls
64 lines (50 loc) · 1.99 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const giftScreen = document.getElementById('gift-screen');
const contentScreen = document.getElementById('content-screen');
const giftButton = document.getElementById('gift-button');
const bgMusic = document.getElementById('bg-music');
const paperPages = document.querySelectorAll('.paper-page');
const surpriseBtn = document.getElementById('surprise');
const surpriseScreen = document.getElementById('surprise-screen');
const surpriseVideo = document.getElementById('Svideo');
const paperPages1 = document.querySelectorAll('.paper-page-1');
bgMusic.volume = 0.3;
surpriseVideo.play();
surpriseVideo.pause();
giftButton.addEventListener('click', () => {
// 1. Play the music safely following native browser rules
bgMusic.play().catch(error => {
console.log("Audio play blocked or failed: ", error);
});
// 2. Smoothly fade out the gift box cover screen
giftScreen.style.opacity = '0';
setTimeout(() => {
giftScreen.style.display = 'none';
}, 800);
// 3. Make the scrolling page content visible
contentScreen.classList.add('show-screen');
// 4. Cascade animate the cards falling into place cleanly
paperPages.forEach((page, index) => {
setTimeout(() => {
page.classList.add('animate-card');
}, 400 + (index * 250)); // Staggered delays for a fluid presentation drop
});
});
surpriseBtn.addEventListener('click', () => {
bgMusic.pause();
contentScreen.style.opacity = '0';
setTimeout(() => {
contentScreen.style.display = 'none';
}, 200);
surpriseScreen.classList.remove('hidden');
surpriseScreen.classList.add('show-screen');
setTimeout(() => {
surpriseVideo.play().catch(error => {
console.log("Video play blocked or failed: ", error);
});
}, 1000);
paperPages1.forEach((page, index) => {
setTimeout(() => {
page.classList.add('animate-card');
}, 400 + (index * 250)); // Staggered delays for a fluid presentation drop
});
});