@@ -34,10 +34,7 @@ import {
3434import { getIframe , preloadBootstrap } from '../../../src/3p-frame' ;
3535import { intersectionEntryToJson } from '#core/dom/layout/intersection' ;
3636import { moveLayoutRect } from '#core/dom/layout/rect' ;
37- import {
38- observeWithSharedInOb ,
39- unobserveWithSharedInOb ,
40- } from '#core/dom/layout/viewport-observer' ;
37+ import { observeIntersections } from '#core/dom/layout/viewport-observer' ;
4138import { toWin } from '#core/window' ;
4239
4340/** @const {string} Tag name for 3P AD implementation. */
@@ -129,6 +126,9 @@ export class AmpAd3PImpl extends AMP.BaseElement {
129126 * @private {boolean}
130127 */
131128 this . isFullWidthRequested_ = false ;
129+
130+ /** @private {?UnlistenDef} */
131+ this . unobserveIntersections_ = null ;
132132 }
133133
134134 /** @override */
@@ -409,8 +409,9 @@ export class AmpAd3PImpl extends AMP.BaseElement {
409409 return this . xOriginIframeHandler_ . init ( iframe ) ;
410410 } )
411411 . then ( ( ) => {
412- observeWithSharedInOb ( this . element , ( inViewport ) =>
413- this . viewportCallback_ ( inViewport )
412+ this . unobserveIntersections_ = observeIntersections (
413+ this . element ,
414+ ( { isIntersecting} ) => this . viewportCallback_ ( isIntersecting )
414415 ) ;
415416 } ) ;
416417 incrementLoadingAds ( this . win , this . layoutPromise_ ) ;
@@ -436,7 +437,8 @@ export class AmpAd3PImpl extends AMP.BaseElement {
436437 unlayoutCallback ( ) {
437438 this . unlisteners_ . forEach ( ( unlisten ) => unlisten ( ) ) ;
438439 this . unlisteners_ . length = 0 ;
439- unobserveWithSharedInOb ( this . element ) ;
440+ this . unobserveIntersections_ ?. ( ) ;
441+ this . unobserveIntersections = null ;
440442
441443 this . layoutPromise_ = null ;
442444 this . uiHandler . applyUnlayoutUI ( ) ;
0 commit comments