@@ -457,7 +457,11 @@ const VIEWPORT_FUDGE_FACTOR = -3; // px
457
457
const MIN_VIEW_TIME_ROTATION_DURATION = 45 ; // seconds
458
458
const MAX_ROTATIONS = 3 ;
459
459
460
+ // Enable ad rotation on hash change (intra-site nav)
461
+ const HASHCHANGE_ROTATION_ENABLE = true ;
462
+
460
463
// Seconds after a tab comes back into focus to rotate an ad.
464
+ const VISIBILITYCHANGE_ROTATION_ENABLE = false ;
461
465
const VISIBILITYCHANGE_ROTATION_DELAY = 3 ; // seconds
462
466
463
467
/* Placement object to query decision API and return an Element node
@@ -648,7 +652,9 @@ export class Placement {
648
652
placement . rotate ( ) ;
649
653
}
650
654
} ;
651
- window . addEventListener ( "hashchange" , placement . hashchange_listener ) ;
655
+ if ( HASHCHANGE_ROTATION_ENABLE ) {
656
+ window . addEventListener ( "hashchange" , placement . hashchange_listener ) ;
657
+ }
652
658
653
659
// Listens to the window visibility
654
660
// Rotates the ad when the window comes back into focus if
@@ -683,10 +689,12 @@ export class Placement {
683
689
}
684
690
}
685
691
} ;
686
- document . addEventListener (
687
- "visibilitychange" ,
688
- placement . visibilitychange_listener
689
- ) ;
692
+ if ( VISIBILITYCHANGE_ROTATION_ENABLE ) {
693
+ document . addEventListener (
694
+ "visibilitychange" ,
695
+ placement . visibilitychange_listener
696
+ ) ;
697
+ }
690
698
691
699
return this ;
692
700
} ) ;
@@ -698,11 +706,11 @@ export class Placement {
698
706
clearInterval ( this . view_time_counter ) ;
699
707
}
700
708
701
- if ( this . hashchange_listener ) {
709
+ if ( this . hashchange_listener && HASHCHANGE_ROTATION_ENABLE ) {
702
710
window . removeEventListener ( "hashchange" , this . hashchange_listener ) ;
703
711
}
704
712
705
- if ( this . visibilitychange_listener ) {
713
+ if ( this . visibilitychange_listener && VISIBILITYCHANGE_ROTATION_ENABLE ) {
706
714
document . removeEventListener (
707
715
"visibilitychange" ,
708
716
this . visibilitychange_listener
0 commit comments