소스 검색

fix scroll front cover

master
farhan 5 달 전
부모
커밋
427d5cbf82
1개의 변경된 파일20개의 추가작업 그리고 7개의 파일을 삭제
  1. 20
    7
      resources/views/digital-card.blade.php

+ 20
- 7
resources/views/digital-card.blade.php 파일 보기

@@ -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) {

Loading…
취소
저장