瀏覽代碼

scroll to top to close back the card

master
farhan 4 月之前
父節點
當前提交
ca46cd1f11
共有 1 個檔案被更改,包括 10 行新增1 行删除
  1. 10
    1
      resources/js/app.js

+ 10
- 1
resources/js/app.js 查看文件

@@ -171,7 +171,16 @@ document.addEventListener('DOMContentLoaded', function() {
171 171
     }
172 172
 
173 173
     // Listen for click or touch event to start auto-scrolling
174
-    window.addEventListener('click', handleInteraction, { once: true });
174
+    window.addEventListener('click', handleInteraction);
175
+
176
+    window.addEventListener('scroll', function() {
177
+        if (window.pageYOffset === 0) {
178
+            audioElement.pause();
179
+            document.getElementById('petalOverlay').style.display = 'none';
180
+            hasPlayed = false; // Reset to allow replay
181
+            document.body.classList.add('no-scroll');
182
+        }
183
+    });
175 184
 
176 185
      // Intersection Observer for fading in elements
177 186
     const observerOptions = {

Loading…
取消
儲存