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

Method collapseFrame

ads/inabox/frame-overlay-manager.js:63–88  ·  view source on GitHub ↗

* Collapses an iframe back from full overlay. * @param {!HTMLIFrameElement} iframe * @param {!Function} callback Gets executed when collapsed with the new box * rect.

(iframe, callback)

Source from the content-addressed store, hash-verified

61 * rect.
62 */
63 collapseFrame(iframe, callback) {
64 // There is a delay of one animation frame between collapsing and measuring
65 // the box rect. collapseFrame() takes a callback for each event.
66 //
67 // We know what the collapsed box was. If the viewport has not changed while
68 // expanded, we can immediately notify the consumer of the collapsed
69 // box rect since it should be the same. Otherwise, we wait for remeasure.
70 collapseFrame(
71 this.win_,
72 iframe,
73 () => {
74 this.isExpanded_ = false;
75
76 if (!this.viewportChangedSinceExpand_) {
77 callback(this.collapsedRect_);
78 }
79 },
80 (collapsedRect) => {
81 this.collapsedRect_ = collapsedRect;
82
83 if (this.viewportChangedSinceExpand_) {
84 callback(this.collapsedRect_);
85 }
86 }
87 );
88 }
89}
90
91/**

Calls 1

callbackFunction · 0.50

Tested by

no test coverage detected