|
@@ -55,35 +55,42 @@ const countdownTimer = setInterval(() => {
|
55
|
55
|
$(function() {
|
56
|
56
|
var partLeftPos = 0;
|
57
|
57
|
var partRightPos = 0;
|
58
|
|
-
|
|
58
|
+ var scrollTimeout;
|
|
59
|
+
|
|
60
|
+ function debounceScroll() {
|
|
61
|
+ clearTimeout(scrollTimeout);
|
|
62
|
+ scrollTimeout = setTimeout(function() {
|
|
63
|
+ var distance = $(window).scrollTop() * 2;
|
|
64
|
+ var left = partLeftPos - distance;
|
|
65
|
+ var right = partRightPos - distance;
|
|
66
|
+
|
|
67
|
+ $('.left').css('left', left + "px");
|
|
68
|
+ $('.right').css('right', right + "px");
|
|
69
|
+
|
|
70
|
+ // Calculate boundaries
|
|
71
|
+ var leftPartRightEdge = $('.left').offset().left + $('.left').outerWidth();
|
|
72
|
+
|
|
73
|
+ // Check if both parts are completely off-screen
|
|
74
|
+ var isLeftOffScreen = leftPartRightEdge <= 0;
|
|
75
|
+
|
|
76
|
+ // Toggle visibility and z-index
|
|
77
|
+ if (isLeftOffScreen && left < 0) {
|
|
78
|
+ $('.parent').removeClass(['z-30']);
|
|
79
|
+ } else {
|
|
80
|
+ $('.parent').addClass(['z-30']);
|
|
81
|
+ }
|
|
82
|
+ }, 100); // Adjust debounce delay as needed (in milliseconds)
|
|
83
|
+ }
|
|
84
|
+
|
59
|
85
|
$(window).scroll(function(event) {
|
60
|
|
- var distance = $(this).scrollTop() * 2;
|
61
|
|
- var left = partLeftPos - distance;
|
62
|
|
- var right = partRightPos - distance;
|
63
|
|
-
|
64
|
|
- $('.left').css('left', left + "px");
|
65
|
|
- $('.right').css('right', right + "px");
|
66
|
|
-
|
67
|
|
- // Calculate boundaries
|
68
|
|
- var leftPartRightEdge = $('.left').offset().left + $('.left').outerWidth();
|
69
|
|
-
|
70
|
|
- // Check if both parts are completely off-screen
|
71
|
|
- var isLeftOffScreen = leftPartRightEdge <= 0;
|
72
|
|
-
|
73
|
|
- // Toggle visibility and z-index
|
74
|
|
- if (isLeftOffScreen && left < 0) {
|
75
|
|
- $('.parent').removeClass(['z-30']);
|
76
|
|
- } else {
|
77
|
|
- $('.parent').addClass(['z-30']);
|
78
|
|
- }
|
|
86
|
+ debounceScroll();
|
79
|
87
|
});
|
80
|
88
|
|
81
|
89
|
// Initially check visibility on page load
|
82
|
90
|
$(window).trigger('scroll');
|
83
|
|
-
|
84
|
|
-
|
85
|
91
|
});
|
86
|
92
|
|
|
93
|
+
|
87
|
94
|
document.addEventListener('click', function () {
|
88
|
95
|
setTimeout(function () {
|
89
|
96
|
document.getElementById('petalOverlay').style.display = 'block';
|