Browse Source

revert smooth scroll

master
farhan 5 months ago
parent
commit
e353441a66
1 changed files with 8 additions and 21 deletions
  1. 8
    21
      resources/views/digital-card.blade.php

+ 8
- 21
resources/views/digital-card.blade.php View File

@@ -69,7 +69,7 @@
69 69
                 var audioElement = document.getElementById('player');
70 70
                 var hasPlayed = false; // To ensure audio only plays once upon clicking and scrolling
71 71
                 var scrollCount = 0;
72
-                var maxScrolls = 8;
72
+                var maxScrolls = 6;
73 73
                 var scrollInterval = 500; // Time in milliseconds between each scroll
74 74
                 var scrollAmount = window.innerHeight / 6; // Amount to scroll per interval
75 75
     
@@ -91,30 +91,17 @@
91 91
                 }
92 92
     
93 93
                 function smoothScroll() {
94
-                if (!hasPlayed) {
95
-                    playAudio();
96
-                    scrollCount++;
97
-                    if (scrollCount >= maxScrolls) {
94
+                    if (!hasPlayed) {
98 95
                         playAudio();
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 += 1); // Adjust speed here (e.g., +=5)
108
-                                requestAnimationFrame(scrollStep);
109
-                            }
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);
110 102
                         }
111
-
112
-                        scrollStep(); // Initiates the smooth scrolling process
113
-                        setTimeout(smoothScroll, scrollInterval); // Continues scrolling after a delay
114 103
                     }
115 104
                 }
116
-}
117
-
118 105
 
119 106
                 function playOnly() {
120 107
                     if (!hasPlayed) {

Loading…
Cancel
Save