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

Method stepMutate_

src/utils/animation.js:281–319  ·  view source on GitHub ↗

* @param {!{[key: string]: *}} unusedState * @private

(unusedState)

Source from the content-addressed store, hash-verified

279 * @private
280 */
281 stepMutate_(unusedState) {
282 if (!this.running_) {
283 return;
284 }
285 const currentTime = Date.now();
286 const normLinearTime = Math.min(
287 (currentTime - this.startTime_) / this.duration_,
288 1
289 );
290
291 // Start segments due to be started
292 for (let i = 0; i < this.segments_.length; i++) {
293 const segment = this.segments_[i];
294 if (!segment.started && normLinearTime >= segment.delay) {
295 segment.started = true;
296 }
297 }
298
299 // Execute all pending segments.
300 for (let i = 0; i < this.segments_.length; i++) {
301 const segment = this.segments_[i];
302 if (!segment.started || segment.completed) {
303 continue;
304 }
305 this.mutateSegment_(segment, normLinearTime);
306 }
307
308 // Complete or start next cycle.
309 if (normLinearTime == 1) {
310 this.complete_(/* success */ true, /* dir */ 0);
311 } else {
312 if (this.vsync_.canAnimate(this.contextNode_)) {
313 this.task_(this.state_);
314 } else {
315 dev().warn(TAG_, 'cancel animation');
316 this.complete_(/* success */ false, /* dir */ 0);
317 }
318 }
319 }
320
321 /**
322 * @param {!SegmentRuntimeDef} segment

Callers

nothing calls this directly

Calls 6

mutateSegment_Method · 0.95
complete_Method · 0.95
devFunction · 0.90
nowMethod · 0.80
warnMethod · 0.80
canAnimateMethod · 0.45

Tested by

no test coverage detected