|
@@ -3,59 +3,11 @@ import './bootstrap';
|
3
|
3
|
import '@fortawesome/fontawesome-free/css/all.min.css';
|
4
|
4
|
|
5
|
5
|
|
6
|
|
-//Countdown date (adjust this date to your desired countdown target)
|
7
|
|
-const countdownDate = new Date('2024-08-17T11:00:00').getTime();
|
8
|
|
-
|
9
|
|
-//Update the countdown every second
|
10
|
|
-const countdownElement = document.getElementById('countdown');
|
11
|
|
-const countdownTimer = setInterval(() => {
|
12
|
|
- //Get the current date and time
|
13
|
|
- const now = new Date().getTime();
|
14
|
|
-
|
15
|
|
- //Calculate the time remaining
|
16
|
|
- const distance = countdownDate - now;
|
17
|
|
-
|
18
|
|
- //Calculate days, hours, minutes, and seconds
|
19
|
|
- const days = Math.floor(distance / (1000 * 60 * 60 * 24));
|
20
|
|
- const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
21
|
|
- const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
22
|
|
- const seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
23
|
|
-
|
24
|
|
- //Format the countdown into a string
|
25
|
|
- const countdownHTML = `
|
26
|
|
- <div class="flex flex-col">
|
27
|
|
- <div class="flex gap-8 justify-center">
|
28
|
|
- <div class="font-medium text-gray-500">${days}</div>
|
29
|
|
- <div class="font-medium text-gray-500">:</div>
|
30
|
|
- <div class="font-medium text-gray-500">${hours.toString().padStart(2, '0')}</div>
|
31
|
|
- <div class="font-medium text-gray-500">:</div>
|
32
|
|
- <div class="font-medium text-gray-500">${minutes.toString().padStart(2, '0')}</div>
|
33
|
|
- <div class="font-medium text-gray-500">:</div>
|
34
|
|
- <div class="font-medium text-gray-500">${seconds.toString().padStart(2, '0')}</div>
|
35
|
|
- </div>
|
36
|
|
- <div class="flex gap-14 justify-center">
|
37
|
|
- <div class="font-medium text-gray-600">Hari</div>
|
38
|
|
- <div class="font-medium text-gray-600">Jam</div>
|
39
|
|
- <div class="font-medium text-gray-600">Minit</div>
|
40
|
|
- <div class="font-medium text-gray-600">Saat</div>
|
41
|
|
- </div>
|
42
|
|
- </div>
|
43
|
|
- `;
|
44
|
|
-
|
45
|
|
- //Display the countdown in the element
|
46
|
|
- countdownElement.innerHTML = countdownHTML;
|
47
|
|
-
|
48
|
|
- //If the countdown is over, clear the timer and display a message
|
49
|
|
- if (distance < 0) {
|
50
|
|
- clearInterval(countdownTimer);
|
51
|
|
- countdownElement.innerHTML = 'Majlis berlangsung';
|
52
|
|
- }
|
53
|
|
-}, 1000); // Update every second (1000 milliseconds)
|
54
|
6
|
|
55
|
7
|
document.addEventListener('DOMContentLoaded', function () {
|
56
|
|
- imageLoading()
|
57
|
|
- scrollOpenCover()
|
58
|
8
|
|
|
9
|
+ imageLoading()
|
|
10
|
+ scrollOpenCover();
|
59
|
11
|
reset() // reset everrything to ensure smooth
|
60
|
12
|
sessionStorage.setItem("initial-load", "true"); // will be used by click event
|
61
|
13
|
|
|
@@ -66,48 +18,82 @@ document.addEventListener('click', function () {
|
66
|
18
|
|
67
|
19
|
let initLoad = sessionStorage.getItem("initial-load")
|
68
|
20
|
|
69
|
|
-
|
70
|
21
|
// parts is intro cover
|
71
|
22
|
let parts = document.getElementsByClassName("part");
|
72
|
23
|
for (let part of parts) {
|
73
|
24
|
part.classList.add("shadow-lg")
|
74
|
25
|
}
|
75
|
26
|
|
76
|
|
- let body = document.querySelector("body");
|
77
|
|
- body.classList.remove("no-scroll");
|
78
|
|
-
|
79
|
27
|
// the intro - only done once and
|
80
|
28
|
if (initLoad == "true") {
|
81
|
29
|
playMusic();
|
|
30
|
+
|
|
31
|
+ let leftCover = document.querySelector(".dummy-cover .left-dummy");
|
|
32
|
+ let rightCover = document.querySelector(".dummy-cover .right-dummy");
|
|
33
|
+ leftCover.classList.add("to-left-animation")
|
|
34
|
+ rightCover.classList.add("to-right-animation")
|
|
35
|
+ setTimeout(()=>{
|
|
36
|
+ //dummy-cover
|
|
37
|
+ let parts = document.querySelectorAll(".dummy-cover .part");
|
|
38
|
+ for (let part of parts) {
|
|
39
|
+ part.remove("hidden")
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ let body = document.querySelector("body");
|
|
43
|
+ body.classList.remove("no-scroll");
|
|
44
|
+
|
|
45
|
+ },2500)
|
|
46
|
+
|
82
|
47
|
sessionStorage.removeItem("initial-load")
|
83
|
|
- // delay timer to have that umpph feels my G
|
84
|
|
- setTimeout(() => {
|
85
|
|
- // smooth scroll only happen for first render
|
86
|
|
- smoothScrollBy(100, 3500);
|
87
|
|
- }, 500)
|
88
|
48
|
}
|
89
|
49
|
|
|
50
|
+ setTimeout(() => {
|
|
51
|
+ eventCountdown();
|
|
52
|
+ let petalOverlay = document.getElementById("petalOverlay");
|
|
53
|
+ petalOverlay.classList.remove("hidden");
|
|
54
|
+ }, 2000)
|
|
55
|
+
|
90
|
56
|
});
|
91
|
57
|
|
92
|
|
-function smoothScrollBy(distance, duration) {
|
93
|
|
- const start = window.pageYOffset;
|
94
|
|
- const startTime = performance.now();
|
|
58
|
+// to ensure all images is loaded before starting animation and gimmick
|
|
59
|
+function imageLoading() {
|
|
60
|
+ const images = document.querySelectorAll("img");
|
|
61
|
+ let loadedCount = 0;
|
|
62
|
+ const totalImages = images.length;
|
|
63
|
+
|
|
64
|
+ images.forEach(image => {
|
|
65
|
+ if (image.complete) {
|
|
66
|
+ loadedCount++;
|
|
67
|
+ } else {
|
|
68
|
+ image.addEventListener("load", () => {
|
|
69
|
+ loadedCount++;
|
|
70
|
+ checkAllImagesLoaded();
|
|
71
|
+ });
|
|
72
|
+ image.addEventListener("error", () => {
|
|
73
|
+ loadedCount++;
|
|
74
|
+ checkAllImagesLoaded();
|
|
75
|
+ });
|
|
76
|
+ }
|
|
77
|
+ });
|
95
|
78
|
|
96
|
|
- function scroll() {
|
97
|
|
- const now = performance.now();
|
98
|
|
- const time = Math.min(1, (now - startTime) / duration);
|
99
|
|
- const timeFunction = time * (2 - time); // Ease out effect
|
100
|
|
- window.scrollTo(0, start + timeFunction * distance);
|
|
79
|
+ function checkAllImagesLoaded() {
|
101
|
80
|
|
102
|
|
- if (time < 1) {
|
103
|
|
- requestAnimationFrame(scroll);
|
|
81
|
+ if (loadedCount === totalImages) {
|
|
82
|
+ let loading = document.getElementById("loading");
|
|
83
|
+ loading.remove();
|
|
84
|
+ // parts is intro cover
|
|
85
|
+ let parts = document.getElementsByClassName("part");
|
|
86
|
+ for (let part of parts) {
|
|
87
|
+ part.classList.remove("hidden")
|
|
88
|
+ }
|
104
|
89
|
}
|
105
|
90
|
}
|
106
|
91
|
|
107
|
|
- requestAnimationFrame(scroll);
|
|
92
|
+ //somehow the server work so fast, script doesn't have much time to set the load eventlistener
|
|
93
|
+ //thus we check here, to ensure checkAllImagesLoaded run
|
|
94
|
+ checkAllImagesLoaded();
|
108
|
95
|
}
|
109
|
96
|
|
110
|
|
-
|
111
|
97
|
// enable open close cover
|
112
|
98
|
function scrollOpenCover() {
|
113
|
99
|
var partLeftPos = 0;
|
|
@@ -151,53 +137,16 @@ function scrollOpenCover() {
|
151
|
137
|
});
|
152
|
138
|
}
|
153
|
139
|
|
154
|
|
-// to ensure all images is loaded before starting animation and gimmick
|
155
|
|
-function imageLoading() {
|
156
|
|
- const images = document.querySelectorAll("img");
|
157
|
|
- let loadedCount = 0;
|
158
|
|
- const totalImages = images.length;
|
159
|
|
-
|
160
|
|
- images.forEach(image => {
|
161
|
|
- if (image.complete) {
|
162
|
|
- loadedCount++;
|
163
|
|
- } else {
|
164
|
|
- image.addEventListener("load", () => {
|
165
|
|
- loadedCount++;
|
166
|
|
- checkAllImagesLoaded();
|
167
|
|
- });
|
168
|
|
- image.addEventListener("error", () => {
|
169
|
|
- loadedCount++;
|
170
|
|
- checkAllImagesLoaded();
|
171
|
|
- });
|
172
|
|
- }
|
173
|
|
- });
|
174
|
|
-
|
175
|
|
- function checkAllImagesLoaded() {
|
176
|
|
- if (loadedCount === totalImages) {
|
177
|
|
- let loading = document.getElementById("loading");
|
178
|
|
- loading.remove();
|
179
|
|
- // parts is intro cover
|
180
|
|
- let parts = document.getElementsByClassName("part");
|
181
|
|
- for (let part of parts) {
|
182
|
|
- part.classList.remove("hidden")
|
183
|
|
- }
|
184
|
|
-
|
185
|
|
- }
|
186
|
|
- }
|
187
|
|
-}
|
188
|
|
-
|
189
|
140
|
function reset() {
|
|
141
|
+
|
190
|
142
|
// reset to top
|
191
|
143
|
let body = document.querySelector("body");
|
192
|
|
- body.classList.remove("no-scroll");
|
193
|
|
- window.scrollTo(0, 0);
|
|
144
|
+ window.scrollTo(0, document.body.scrollHeight * 0.05);
|
|
145
|
+ body.classList.add("no-scroll");
|
194
|
146
|
|
195
|
|
- setTimeout(() => {
|
196
|
|
- body.classList.add("no-scroll");
|
197
|
|
- }, 500)
|
198
|
147
|
}
|
199
|
148
|
|
200
|
|
-function playMusic(){
|
|
149
|
+function playMusic() {
|
201
|
150
|
var audioElement = document.getElementById('player');
|
202
|
151
|
var hasPlayed = false;
|
203
|
152
|
if (!hasPlayed) {
|
|
@@ -205,13 +154,65 @@ function playMusic(){
|
205
|
154
|
var playPromise = audioElement.play();
|
206
|
155
|
|
207
|
156
|
if (playPromise !== undefined) {
|
208
|
|
- playPromise.then(function() {
|
|
157
|
+ playPromise.then(function () {
|
209
|
158
|
// Automatic playback started!
|
210
|
159
|
hasPlayed = true; // Prevent further attempts to play
|
211
|
|
- }).catch(function(error) {
|
|
160
|
+ }).catch(function (error) {
|
212
|
161
|
// Automatic playback failed.
|
213
|
162
|
console.log('Autoplay failed: ' + error);
|
214
|
163
|
});
|
215
|
164
|
}
|
216
|
165
|
}
|
217
|
166
|
}
|
|
167
|
+
|
|
168
|
+function eventCountdown() {
|
|
169
|
+
|
|
170
|
+ //Countdown date (adjust this date to your desired countdown target)
|
|
171
|
+ const countdownDate = new Date('2024-08-17T11:00:00').getTime();
|
|
172
|
+
|
|
173
|
+ //Update the countdown every second
|
|
174
|
+ const countdownElement = document.getElementById('countdown');
|
|
175
|
+ const countdownTimer = setInterval(() => {
|
|
176
|
+ //Get the current date and time
|
|
177
|
+ const now = new Date().getTime();
|
|
178
|
+
|
|
179
|
+ //Calculate the time remaining
|
|
180
|
+ const distance = countdownDate - now;
|
|
181
|
+
|
|
182
|
+ //Calculate days, hours, minutes, and seconds
|
|
183
|
+ const days = Math.floor(distance / (1000 * 60 * 60 * 24));
|
|
184
|
+ const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
|
185
|
+ const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
|
186
|
+ const seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
|
187
|
+
|
|
188
|
+ //Format the countdown into a string
|
|
189
|
+ const countdownHTML = `
|
|
190
|
+ <div class="flex flex-col">
|
|
191
|
+ <div class="flex gap-8 justify-center">
|
|
192
|
+ <div class="font-medium text-gray-500">${days}</div>
|
|
193
|
+ <div class="font-medium text-gray-500">:</div>
|
|
194
|
+ <div class="font-medium text-gray-500">${hours.toString().padStart(2, '0')}</div>
|
|
195
|
+ <div class="font-medium text-gray-500">:</div>
|
|
196
|
+ <div class="font-medium text-gray-500">${minutes.toString().padStart(2, '0')}</div>
|
|
197
|
+ <div class="font-medium text-gray-500">:</div>
|
|
198
|
+ <div class="font-medium text-gray-500">${seconds.toString().padStart(2, '0')}</div>
|
|
199
|
+ </div>
|
|
200
|
+ <div class="flex gap-14 justify-center">
|
|
201
|
+ <div class="font-medium text-gray-600">Hari</div>
|
|
202
|
+ <div class="font-medium text-gray-600">Jam</div>
|
|
203
|
+ <div class="font-medium text-gray-600">Minit</div>
|
|
204
|
+ <div class="font-medium text-gray-600">Saat</div>
|
|
205
|
+ </div>
|
|
206
|
+ </div>
|
|
207
|
+ `;
|
|
208
|
+
|
|
209
|
+ //Display the countdown in the element
|
|
210
|
+ countdownElement.innerHTML = countdownHTML;
|
|
211
|
+
|
|
212
|
+ //If the countdown is over, clear the timer and display a message
|
|
213
|
+ if (distance < 0) {
|
|
214
|
+ clearInterval(countdownTimer);
|
|
215
|
+ countdownElement.innerHTML = 'Majlis berlangsung';
|
|
216
|
+ }
|
|
217
|
+ }, 1000); // Update every second (1000 milliseconds)
|
|
218
|
+}
|