Quellcode durchsuchen

fix scroll front cover

master
farhan vor 5 Monaten
Ursprung
Commit
427d5cbf82
1 geänderte Dateien mit 20 neuen und 7 gelöschten Zeilen
  1. 20
    7
      resources/views/digital-card.blade.php

+ 20
- 7
resources/views/digital-card.blade.php Datei anzeigen

@@ -91,17 +91,30 @@
91 91
                 }
92 92
     
93 93
                 function smoothScroll() {
94
-                    if (!hasPlayed) {
94
+                if (!hasPlayed) {
95
+                    playAudio();
96
+                    scrollCount++;
97
+                    if (scrollCount >= maxScrolls) {
95 98
                         playAudio();
96
-                        scrollCount++;
97
-                        if (scrollCount >= maxScrolls) {
98
-                            playAudio();
99
-                        } else {
100
-                            window.scrollBy(0, scrollAmount); // Smooth scroll a fraction of the window height
101
-                            setTimeout(playOnly, scrollInterval);
99
+                    } else {
100
+                        // Calculate scroll position
101
+                        var currentScroll = window.pageYOffset || document.documentElement.scrollTop;
102
+                        var targetScroll = currentScroll + scrollAmount;
103
+
104
+                        // Smooth scroll using requestAnimationFrame
105
+                        function scrollStep() {
106
+                            if (currentScroll < targetScroll) {
107
+                                window.scrollTo(0, currentScroll += 5); // Adjust speed here (e.g., +=5)
108
+                                requestAnimationFrame(scrollStep);
109
+                            }
102 110
                         }
111
+
112
+                        scrollStep(); // Initiates the smooth scrolling process
113
+                        setTimeout(smoothScroll, scrollInterval); // Continues scrolling after a delay
103 114
                     }
104 115
                 }
116
+}
117
+
105 118
 
106 119
                 function playOnly() {
107 120
                     if (!hasPlayed) {

Laden…
Abbrechen
Speichern