@@ -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