MCPcopy Index your code
hub / github.com/ampproject/amphtml / transformMutate

Method transformMutate

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

* Apply or reset transform style to fixed elements. The existing transition, * if any, is disabled when custom transform is supplied. * @param {?string} transform

(transform)

Source from the content-addressed store, hash-verified

283 * @param {?string} transform
284 */
285 transformMutate(transform) {
286 // Unfortunately, we can't do anything with sticky elements here. Updating
287 // `top` in animation frames causes reflow on all platforms and we can't
288 // determine whether an element is currently docked to apply transform.
289 if (transform) {
290 // Apply transform style to all fixed elements
291 this.elements_.forEach((e) => {
292 if (e.fixedNow && e.top) {
293 setStyle(e.element, 'transition', 'none');
294 if (e.transform && e.transform != 'none') {
295 setStyle(e.element, 'transform', e.transform + ' ' + transform);
296 } else {
297 setStyle(e.element, 'transform', transform);
298 }
299 }
300 });
301 } else {
302 // Reset transform style to all fixed elements
303 this.elements_.forEach((e) => {
304 if (e.fixedNow && e.top) {
305 setStyles(e.element, {
306 transform: '',
307 transition: '',
308 });
309 }
310 });
311 }
312 }
313
314 /**
315 * Adds the element directly into the fixed/sticky layer, bypassing discovery.

Callers 2

animateFixedElementsMethod · 0.95

Calls 3

setStyleFunction · 0.90
setStylesFunction · 0.90
forEachMethod · 0.45

Tested by

no test coverage detected