Browse Source

test

master
farhan 4 months ago
parent
commit
33be218ece
2 changed files with 16 additions and 37 deletions
  1. 4
    0
      resources/css/app.css
  2. 12
    37
      resources/js/app.js

+ 4
- 0
resources/css/app.css View File

@@ -36,6 +36,10 @@
36 36
 html {
37 37
     scroll-behavior: smooth;
38 38
 }
39
+body {
40
+    min-height: 100vh; /* Minimum height of the body */
41
+    overflow-y: scroll; /* Always show vertical scrollbar */
42
+}
39 43
 body.no-scroll {
40 44
     overflow: hidden;
41 45
 }

+ 12
- 37
resources/js/app.js View File

@@ -55,15 +55,13 @@ const countdownTimer = setInterval(() => {
55 55
 $(function() {
56 56
     var partLeftPos = 0;
57 57
     var partRightPos = 0;
58
-    var isScrolling = false;
59
-    var lastScrollTop = 0;
60
-
58
+    
59
+    // Function to update positions of .left and .right elements
61 60
     function updatePositions() {
62
-        var scrollTop = $(window).scrollTop();
63
-        var distance = scrollTop * 2;
61
+        var distance = $(window).scrollTop() * 2;
64 62
         var left = partLeftPos - distance;
65 63
         var right = partRightPos - distance;
66
-
64
+        
67 65
         $('.left').css('left', left + "px");
68 66
         $('.right').css('right', right + "px");
69 67
 
@@ -84,39 +82,16 @@ $(function() {
84 82
     // Initial positions update
85 83
     updatePositions();
86 84
 
87
-    // Debounce function for scroll events
88
-    function debounce(func, delay) {
89
-        var timeout;
90
-        return function() {
91
-            var context = this;
92
-            var args = arguments;
93
-            var later = function() {
94
-                timeout = null;
95
-                func.apply(context, args);
96
-            };
97
-            clearTimeout(timeout);
98
-            timeout = setTimeout(later, delay);
99
-        };
100
-    }
101
-
102
-    // Update positions on scroll using requestAnimationFrame for smoother animation
103
-    function scrollHandler() {
104
-        if (!isScrolling) {
105
-            window.requestAnimationFrame(function() {
106
-                updatePositions();
107
-                isScrolling = false;
108
-            });
109
-        }
110
-        isScrolling = true;
111
-    }
112
-
113
-    // Listen to scroll events and debounce them for better performance
114
-    $(window).scroll(debounce(scrollHandler, 20));
115
-
116
-    // Handle window resize to recalculate positions if needed
117
-    $(window).resize(function() {
85
+    // Update positions on scroll
86
+    $(window).scroll(function() {
118 87
         updatePositions();
119 88
     });
89
+
90
+    // Ensure scrollbar visibility
91
+    $('body').css({
92
+        'min-height': '100vh', // Set minimum height to viewport height
93
+        'overflow-y': 'scroll' // Always show vertical scrollbar
94
+    });
120 95
 });
121 96
 
122 97
 

Loading…
Cancel
Save