MCPcopy Create free account
hub / github.com/ampproject/amphtml / intersectionCallback

Function intersectionCallback

examples/ac-creative.js:15–39  ·  view source on GitHub ↗
(changes)

Source from the content-addressed store, hash-verified

13}
14
15function intersectionCallback(changes) {
16 // Code below is simply an example.
17 var latestChange = changes[changes.length - 1];
18
19 var {
20 // Amp-ad width and height.
21 height: h,
22 width: w,
23
24 // Position in the viewport.
25 x: vx,
26 y: vy,
27 } = latestChange.boundingClientRect;
28
29 var {
30 // Visible width and height.
31 height: vh,
32 width: vw,
33 } = latestChange.intersectionRect;
34
35 // Viewable percentage.
36 var viewablePerc = ((vw * vh) / (w * h)) * 100;
37
38 console.log(viewablePerc, w, h, vw, vh, vx, vy);
39}
40
41function dummyCallback(changes) {
42 console.log(changes);

Callers

nothing calls this directly

Calls 1

logMethod · 0.45

Tested by

no test coverage detected