Browse Source

fixing

master
azri 4 months ago
parent
commit
8722735a07
2 changed files with 49 additions and 57 deletions
  1. 46
    10
      resources/css/app.css
  2. 3
    47
      resources/js/app.js

+ 46
- 10
resources/css/app.css View File

105
     box-shadow: 0 0 0 0 #fff;
105
     box-shadow: 0 0 0 0 #fff;
106
 }
106
 }
107
 
107
 
108
-.part{
108
+.part {
109
     transition: all 0.1s ease-in-out;
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
 @keyframes pulsIn {
147
 @keyframes pulsIn {
113
     0% {
148
     0% {
114
         box-shadow: inset 0 0 0 1rem #fff;
149
         box-shadow: inset 0 0 0 1rem #fff;
138
 
173
 
139
 @keyframes to-right {
174
 @keyframes to-right {
140
     from {
175
     from {
141
-       transform: translateX(0)
176
+        transform: translateX(0)
142
     }
177
     }
178
+
143
     to {
179
     to {
144
         transform: translateX(100%)
180
         transform: translateX(100%)
145
-     }
146
-  }
181
+    }
182
+}
147
 
183
 
148
 
184
 
149
 @media (prefers-reduced-motion: no-preference) {
185
 @media (prefers-reduced-motion: no-preference) {
150
     @supports (animation-timeline: scroll()) {
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 View File

53
 }, 1000); // Update every second (1000 milliseconds)
53
 }, 1000); // Update every second (1000 milliseconds)
54
 
54
 
55
 document.addEventListener('DOMContentLoaded', function () {
55
 document.addEventListener('DOMContentLoaded', function () {
56
-    imageLoading()
57
-    scrollOpenCover()
58
 
56
 
57
+    imageLoading()
59
     reset() // reset everrything to ensure smooth
58
     reset() // reset everrything to ensure smooth
60
     sessionStorage.setItem("initial-load", "true"); // will be used by click event
59
     sessionStorage.setItem("initial-load", "true"); // will be used by click event
61
 
60
 
66
 
65
 
67
     let initLoad = sessionStorage.getItem("initial-load")
66
     let initLoad = sessionStorage.getItem("initial-load")
68
 
67
 
69
-
70
     // parts is intro cover
68
     // parts is intro cover
71
     let parts = document.getElementsByClassName("part");
69
     let parts = document.getElementsByClassName("part");
72
     for (let part of parts) {
70
     for (let part of parts) {
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
 // to ensure all images is loaded before starting animation and gimmick
109
 // to ensure all images is loaded before starting animation and gimmick
155
 function imageLoading() {
110
 function imageLoading() {
156
     const images = document.querySelectorAll("img");
111
     const images = document.querySelectorAll("img");
187
 
142
 
188
     //somehow the server work so fast, script doesn't have much time to set the load eventlistener
143
     //somehow the server work so fast, script doesn't have much time to set the load eventlistener
189
     //thus we check here, to ensure checkAllImagesLoaded run
144
     //thus we check here, to ensure checkAllImagesLoaded run
190
-    checkAllImagesLoaded()
145
+    console.log(loadedCount, totalImages);
191
 }
146
 }
192
 
147
 
193
 function reset() {
148
 function reset() {
149
+
194
     // reset to top
150
     // reset to top
195
     let body = document.querySelector("body");
151
     let body = document.querySelector("body");
196
     body.classList.remove("no-scroll");
152
     body.classList.remove("no-scroll");

Loading…
Cancel
Save