azri 4 месяцев назад
Родитель
Сommit
8722735a07
2 измененных файлов: 49 добавлений и 57 удалений
  1. 46
    10
      resources/css/app.css
  2. 3
    47
      resources/js/app.js

+ 46
- 10
resources/css/app.css Просмотреть файл

@@ -105,10 +105,45 @@ body.no-scroll {
105 105
     box-shadow: 0 0 0 0 #fff;
106 106
 }
107 107
 
108
-.part{
108
+.part {
109 109
     transition: all 0.1s ease-in-out;
110 110
 }
111 111
 
112
+@keyframes to-left{
113
+    from{
114
+        transform: translateX(0%);
115
+    }
116
+    to{
117
+        transform: translateX(-100%);
118
+    }
119
+}
120
+
121
+@keyframes to-right{
122
+    from{
123
+        transform: translateX(0%);
124
+    }
125
+    to{
126
+        transform: translateX(100%);
127
+    }
128
+}
129
+
130
+@media (prefers-reduced-motion: no-preference) {
131
+    @supports (animation-timeline: scroll()) {
132
+        .part.left {
133
+            animation: to-left linear both;
134
+            animation-timeline: scroll();
135
+            animation-range-end: 5%;
136
+        }
137
+
138
+        .part.right {
139
+            animation: to-right linear both;
140
+            animation-timeline: scroll();
141
+            animation-range-end: 5%;
142
+        }
143
+    }
144
+}
145
+
146
+
112 147
 @keyframes pulsIn {
113 148
     0% {
114 149
         box-shadow: inset 0 0 0 1rem #fff;
@@ -138,20 +173,21 @@ body.no-scroll {
138 173
 
139 174
 @keyframes to-right {
140 175
     from {
141
-       transform: translateX(0)
176
+        transform: translateX(0)
142 177
     }
178
+
143 179
     to {
144 180
         transform: translateX(100%)
145
-     }
146
-  }
181
+    }
182
+}
147 183
 
148 184
 
149 185
 @media (prefers-reduced-motion: no-preference) {
150 186
     @supports (animation-timeline: scroll()) {
151
-      #right-cover {
152
-        animation: to-right linear both;
153
-        animation-timeline: scroll();
154
-        animation-range: contain;
155
-      }
187
+        #right-cover {
188
+            animation: to-right linear both;
189
+            animation-timeline: scroll();
190
+            animation-range: contain;
191
+        }
156 192
     }
157
-  }
193
+}

+ 3
- 47
resources/js/app.js Просмотреть файл

@@ -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");

Загрузка…
Отмена
Сохранить