Skip to content

Commit

Permalink
Revert "make use of native IntersectionObserver in 3p iframe (ampproj…
Browse files Browse the repository at this point in the history
…ect#6503)" (ampproject#6685)

This reverts commit 7ff2657.
  • Loading branch information
mkhatib authored Dec 15, 2016
1 parent f0d9d17 commit 9e78085
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 40 deletions.
19 changes: 0 additions & 19 deletions 3p/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,6 @@ import {zedo} from '../ads/zedo';
import {zergnet} from '../ads/zergnet';
import {zucks} from '../ads/zucks';

/**
* This value is copied here to avoid importing from src/intersection-observer-polyfill.js
* Please keep this value same with DEFAULT_THRESHOLD from that file.
* @const @private {!Array}
*/
const DEFAULT_THRESHOLD =
[0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4,
0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1];

/**
* Whether the embed type may be used with amp-embed tag.
* @const {!Object<string, boolean>}
Expand Down Expand Up @@ -439,16 +430,6 @@ function triggerRenderStart(opt_data) {
*/
function observeIntersection(observerCallback) {
// Send request to received records.
if (window.IntersectionObserver && window.IntersectionObserver.prototype) {
// use native IntersectionObserver if exist
const io = new window.IntersectionObserver(changes => {
observerCallback(changes);
}, {
threshold: DEFAULT_THRESHOLD,
});
io.observe(window.document.documentElement);
return () => io.unobserve(window.document.documentElement);
}
nonSensitiveDataPostMessage('send-intersections');
return listenParent(window, 'intersection', data => {
observerCallback(data.changes);
Expand Down
13 changes: 2 additions & 11 deletions ads/_ping_.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ import {dev} from '../src/log';
*/
export function _ping_(global, data) {
global.document.getElementById('c').textContent = data.ping;
if (!data.nativeIntersectionObserver) {
const nullIO = () => {};
nullIO.prototype = null;
global.IntersectionObserver = nullIO;
}

if (data.ad_container) {
dev().assert(
global.context.container == data.ad_container, 'wrong container');
Expand All @@ -51,17 +47,12 @@ export function _ping_(global, data) {
} else {
global.context.renderStart();
}
const unlisten = global.context.observeIntersection(function(changes) {
global.context.observeIntersection(function(changes) {
changes.forEach(function(c) {
dev().info('AMP-AD', 'Intersection: (WxH)' +
`${c.intersectionRect.width}x${c.intersectionRect.height}`);
});
});
if (data.unlistenIo) {
global.setTimeout(() => {
unlisten();
}, Number(data.unlistenIo));
}
} else {
global.context.noContentAvailable();
}
Expand Down
2 changes: 0 additions & 2 deletions ads/ads.extern.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ geckoTag.placementReady;
data.plc;
data.sz;
data.extra;
// _ping_
data.nativeIntersectionObserver
var Fusion;
Fusion.on;
Fusion.on.warning;
Expand Down
5 changes: 0 additions & 5 deletions extensions/amp-ad/0.1/amp-ad-3p-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ import {AdDisplayState, AmpAdUIHandler} from './amp-ad-ui';
/** @const {!string} Tag name for 3P AD implementation. */
export const TAG_3P_IMPL = 'amp-ad-3p-impl';

/**
* NOTE: For testing purpose of 3p ad, please consider using ad type `_ping_`,
* as it disables native IntersectionObserver and sends renderStart signal.
*/

export class AmpAd3PImpl extends AMP.BaseElement {

/**
Expand Down
3 changes: 0 additions & 3 deletions test/manual/fakead3p.amp.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ <h2 id="fakead3p_0">fake3pAd send render-start w/ width & height</h2>
data-id='0'
data-url='https://lh3.googleusercontent.com/pSECrJ82R7-AqeBCOEPGPM9iG9OEIQ_QXcbubWIOdkY=w400-h300-no-n'
data-valid='true'
data-native-intersection-observer='true'
data-ad-width=50
data-ad-height=50
</amp-ad>
Expand All @@ -49,8 +48,6 @@ <h2 id="fakead3p_0">fake3pAd send render-start w/o width or height</h2>
data-id='0'
data-url='https://lh3.googleusercontent.com/pSECrJ82R7-AqeBCOEPGPM9iG9OEIQ_QXcbubWIOdkY=w400-h300-no-n'
data-valid='true'
data-native-intersection-observer='true'
data-unlisten-io=1000
</amp-ad>
</div>

Expand Down

0 comments on commit 9e78085

Please sign in to comment.