|
@@ -53,9 +53,8 @@ const countdownTimer = setInterval(() => {
|
53
|
53
|
}, 1000); // Update every second (1000 milliseconds)
|
54
|
54
|
|
55
|
55
|
document.addEventListener('DOMContentLoaded', function () {
|
56
|
|
- imageLoading()
|
57
|
|
- scrollOpenCover()
|
58
|
56
|
|
|
57
|
+ imageLoading()
|
59
|
58
|
reset() // reset everrything to ensure smooth
|
60
|
59
|
sessionStorage.setItem("initial-load", "true"); // will be used by click event
|
61
|
60
|
|
|
@@ -66,7 +65,6 @@ document.addEventListener('click', function () {
|
66
|
65
|
|
67
|
66
|
let initLoad = sessionStorage.getItem("initial-load")
|
68
|
67
|
|
69
|
|
-
|
70
|
68
|
// parts is intro cover
|
71
|
69
|
let parts = document.getElementsByClassName("part");
|
72
|
70
|
for (let part of parts) {
|
|
@@ -108,49 +106,6 @@ function smoothScrollBy(distance, duration) {
|
108
|
106
|
}
|
109
|
107
|
|
110
|
108
|
|
111
|
|
-// enable open close cover
|
112
|
|
-function scrollOpenCover() {
|
113
|
|
- var partLeftPos = 0;
|
114
|
|
- var partRightPos = 0;
|
115
|
|
-
|
116
|
|
- function updatePositions() {
|
117
|
|
- var distance = $(window).scrollTop() * 2;
|
118
|
|
- var left = partLeftPos - distance;
|
119
|
|
- var right = partRightPos - distance;
|
120
|
|
-
|
121
|
|
- $('.left').css('left', left + "px");
|
122
|
|
- $('.right').css('right', right + "px");
|
123
|
|
-
|
124
|
|
- //Calculate boundaries
|
125
|
|
- var leftPartRightEdge = $('.left').offset().left + $('.left').outerWidth();
|
126
|
|
-
|
127
|
|
- //Check if both parts are completely off-screen
|
128
|
|
- var isLeftOffScreen = leftPartRightEdge <= 0;
|
129
|
|
-
|
130
|
|
- //Toggle visibility and z-index
|
131
|
|
- if (isLeftOffScreen && left < 0) {
|
132
|
|
- $('.parent').removeClass('z-30');
|
133
|
|
- } else {
|
134
|
|
- $('.parent').addClass('z-30');
|
135
|
|
- }
|
136
|
|
- }
|
137
|
|
-
|
138
|
|
- //Initial positions update
|
139
|
|
- updatePositions();
|
140
|
|
-
|
141
|
|
- //Listen to scroll events using requestAnimationFrame for smooth animation
|
142
|
|
- var ticking = false;
|
143
|
|
- $(window).scroll(function () {
|
144
|
|
- if (!ticking) {
|
145
|
|
- window.requestAnimationFrame(function () {
|
146
|
|
- updatePositions();
|
147
|
|
- ticking = false;
|
148
|
|
- });
|
149
|
|
- }
|
150
|
|
- ticking = true;
|
151
|
|
- });
|
152
|
|
-}
|
153
|
|
-
|
154
|
109
|
// to ensure all images is loaded before starting animation and gimmick
|
155
|
110
|
function imageLoading() {
|
156
|
111
|
const images = document.querySelectorAll("img");
|
|
@@ -187,10 +142,11 @@ function imageLoading() {
|
187
|
142
|
|
188
|
143
|
//somehow the server work so fast, script doesn't have much time to set the load eventlistener
|
189
|
144
|
//thus we check here, to ensure checkAllImagesLoaded run
|
190
|
|
- checkAllImagesLoaded()
|
|
145
|
+ console.log(loadedCount, totalImages);
|
191
|
146
|
}
|
192
|
147
|
|
193
|
148
|
function reset() {
|
|
149
|
+
|
194
|
150
|
// reset to top
|
195
|
151
|
let body = document.querySelector("body");
|
196
|
152
|
body.classList.remove("no-scroll");
|