File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 29
29
this . nextUrl = null ;
30
30
this . isBound = false ;
31
31
this . isPaused = false ;
32
+ this . isInitialized = false ;
32
33
this . listeners = {
33
34
next : new IASCallbacks ( ) ,
34
35
load : new IASCallbacks ( ) ,
354
355
* @public
355
356
*/
356
357
IAS . prototype . initialize = function ( ) {
358
+ if ( this . isInitialized ) {
359
+ return false ;
360
+ }
361
+
357
362
var supportsOnScroll = ( ! ! ( 'onscroll' in this . $scrollContainer . get ( 0 ) ) ) ,
358
363
currentScrollOffset = this . getCurrentScrollOffset ( this . $scrollContainer ) ,
359
364
scrollThreshold = this . getScrollThreshold ( ) ;
373
378
// start loading next page if content is shorter than page fold
374
379
if ( currentScrollOffset >= scrollThreshold ) {
375
380
this . next ( ) ;
381
+
382
+ // flag as initialized when rendering is completed
383
+ this . one ( 'rendered' , function ( ) {
384
+ this . isInitialized = true ;
385
+ } ) ;
386
+ } else {
387
+ this . isInitialized = true ;
376
388
}
377
389
378
390
return this ;
384
396
* @public
385
397
*/
386
398
IAS . prototype . reinitialize = function ( ) {
399
+ this . isInitialized = false ;
400
+
387
401
this . unbind ( ) ;
388
402
this . initialize ( ) ;
389
403
} ;
557
571
558
572
this . extensions . push ( extension ) ;
559
573
560
- this . reinitialize ( ) ;
574
+ if ( this . isInitialized ) {
575
+ this . reinitialize ( ) ;
576
+ }
561
577
562
578
return this ;
563
579
} ;
You can’t perform that action at this time.
0 commit comments