Skip to content

Commit 6afb44b

Browse files
committed
Add setInterval to deal with window resize event triggering issues
1 parent fdf1058 commit 6afb44b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

assets/js/slider.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const CAROUSEL_SCROLL_DOWN_BUTTON_OFFSET = {X: -5, Y: -25};
33

44
$(document).ready(() => {
55
let slider = $("#slider");
6+
if(slider === null) return;
67
if (slider.length) {
78
slider.slick({
89
dots: true,
@@ -40,5 +41,15 @@ $(document).ready(() => {
4041

4142
// Position carousel scroll-down button
4243
$(window).on("scroll load resize focus blur", recalculate_arrow_position);
44+
// Set interval (necessary for ensuring positioning when resize events don't trigger properly)
45+
$(window).on("resize", () => {
46+
const maxLoops = 10;
47+
let loops = 0;
48+
let tempInterval = setInterval(() => {
49+
if(loops >= maxLoops) clearInterval(tempInterval);
50+
recalculate_arrow_position();
51+
loops++;
52+
}, 100);
53+
});
4354
recalculate_arrow_position();
4455
});

0 commit comments

Comments
 (0)