@@ -558,7 +558,7 @@ define([
558
558
if ( $scrollable . length ) {
559
559
// if scrollable parent and visible -> trigger it
560
560
// we only look at the closest scrollable parent, no nesting
561
- checkVisibility = function inject_checkVisibility_scrollable ( ) {
561
+ checkVisibility = utils . debounce ( function inject_checkVisibility_scrollable ( ) {
562
562
if ( $el . data ( "patterns.autoload" ) )
563
563
return false ;
564
564
var reltop = $el . offset ( ) . top - $scrollable . offset ( ) . top - 1000 ,
@@ -571,28 +571,28 @@ define([
571
571
return trigger ( ) ;
572
572
}
573
573
return false ;
574
- } ;
574
+ } , 100 ) ;
575
575
if ( checkVisibility ( ) )
576
576
return true ;
577
577
578
578
// 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 ) ;
581
581
} else {
582
582
// Use case 2: scrolling the entire page
583
- checkVisibility = function inject_checkVisibility_not_scrollable ( ) {
583
+ checkVisibility = utils . debounce ( function inject_checkVisibility_not_scrollable ( ) {
584
584
if ( $el . data ( "patterns.autoload" ) )
585
585
return false ;
586
586
if ( ! utils . elementInViewport ( $el [ 0 ] ) )
587
587
return false ;
588
588
589
589
$ ( window ) . off ( ".pat-autoload" , checkVisibility ) ;
590
590
return trigger ( ) ;
591
- } ;
591
+ } , 100 ) ;
592
592
if ( checkVisibility ( ) )
593
593
return true ;
594
594
$ ( window ) . on ( "resize.pat-autoload scroll.pat-autoload" ,
595
- utils . debounce ( checkVisibility , 100 ) ) ;
595
+ checkVisibility ) ;
596
596
}
597
597
return false ;
598
598
} ,
0 commit comments