Skip to content

Commit be469ae

Browse files
committed
moved utils.debounce() call to fix removal of event handler, slc ref #10695
1 parent 54ff7ad commit be469ae

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/pat/inject.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ define([
558558
if ($scrollable.length) {
559559
// if scrollable parent and visible -> trigger it
560560
// we only look at the closest scrollable parent, no nesting
561-
checkVisibility = function inject_checkVisibility_scrollable() {
561+
checkVisibility = utils.debounce(function inject_checkVisibility_scrollable() {
562562
if ($el.data("patterns.autoload"))
563563
return false;
564564
var reltop = $el.offset().top - $scrollable.offset().top - 1000,
@@ -571,28 +571,28 @@ define([
571571
return trigger();
572572
}
573573
return false;
574-
};
574+
}, 100);
575575
if (checkVisibility())
576576
return true;
577577

578578
// wait to become visible - again only immediate scrollable parent
579-
$($scrollable[0]).on("scroll", utils.debounce(checkVisibility, 100));
580-
$(window).on("resize.pat-autoload", utils.debounce(checkVisibility, 100));
579+
$($scrollable[0]).on("scroll", checkVisibility);
580+
$(window).on("resize.pat-autoload", checkVisibility);
581581
} else {
582582
// Use case 2: scrolling the entire page
583-
checkVisibility = function inject_checkVisibility_not_scrollable() {
583+
checkVisibility = utils.debounce(function inject_checkVisibility_not_scrollable() {
584584
if ($el.data("patterns.autoload"))
585585
return false;
586586
if (!utils.elementInViewport($el[0]))
587587
return false;
588588

589589
$(window).off(".pat-autoload", checkVisibility);
590590
return trigger();
591-
};
591+
}, 100);
592592
if (checkVisibility())
593593
return true;
594594
$(window).on("resize.pat-autoload scroll.pat-autoload",
595-
utils.debounce(checkVisibility, 100));
595+
checkVisibility);
596596
}
597597
return false;
598598
},

0 commit comments

Comments
 (0)