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

Method canAnimate_

src/service/vsync-impl.js:272–290  ·  view source on GitHub ↗

* @param {!Node=} opt_contextNode * @return {boolean} * @private

(opt_contextNode)

Source from the content-addressed store, hash-verified

270 * @private
271 */
272 canAnimate_(opt_contextNode) {
273 // Window level: animations allowed only when global window is visible.
274 if (isDocumentHidden(this.win.document)) {
275 return false;
276 }
277
278 // Single doc: animations allowed when single doc is visible.
279 if (this.ampdocService_.isSingleDoc()) {
280 return this.ampdocService_.getSingleDoc().isVisible();
281 }
282
283 // Multi-doc: animations depend on the state of the relevant doc.
284 if (opt_contextNode) {
285 const ampdoc = this.ampdocService_.getAmpDocIfAvailable(opt_contextNode);
286 return !ampdoc || ampdoc.isVisible();
287 }
288
289 return true;
290 }
291
292 /**
293 * Runs the animation vsync task. This operation can only run when animations

Callers 4

canAnimateMethod · 0.95
runAnimMethod · 0.95
runAnimMutateSeriesMethod · 0.95
forceSchedule_Method · 0.95

Calls 5

isDocumentHiddenFunction · 0.90
getSingleDocMethod · 0.80
getAmpDocIfAvailableMethod · 0.80
isSingleDocMethod · 0.45
isVisibleMethod · 0.45

Tested by

no test coverage detected