MCPcopy
hub / github.com/ampproject/amphtml / initHiddenObserver_

Method initHiddenObserver_

src/service/fixed-layer.js:246–260  ·  view source on GitHub ↗

* Start observing changes to the hidden attribute, if we haven't already * started.

()

Source from the content-addressed store, hash-verified

244 * started.
245 */
246 initHiddenObserver_() {
247 if (this.hiddenObserverUnlistener_) {
248 return;
249 }
250
251 const root = this.ampdoc.getRootNode();
252 const element = root.documentElement || root;
253 const hiddenObserver = Services.hiddenObserverForDoc(element);
254 this.hiddenObserverUnlistener_ = hiddenObserver.add(() => {
255 if (!this.updatePass_.isPending()) {
256 // Wait one animation frame so that other mutations may arrive.
257 this.updatePass_.schedule(16);
258 }
259 });
260 }
261
262 /**
263 * Updates the viewer's padding-top position and recalculates offsets of

Callers 1

Calls 4

isPendingMethod · 0.80
getRootNodeMethod · 0.45
addMethod · 0.45
scheduleMethod · 0.45

Tested by

no test coverage detected