MCPcopy
hub / github.com/protectwise/troika / gotoElapsedTime

Method gotoElapsedTime

packages/troika-animation/src/Tween.js:61–74  ·  view source on GitHub ↗

* For a given elapsed time relative to the start of the tween, calculates the value at that time and calls the * `callback` function with that value. If the given time is during the `delay` period, the callback will not be * invoked. * @param {number} time

(time)

Source from the content-addressed store, hash-verified

59 * @param {number} time
60 */
61 gotoElapsedTime(time) {
62 let duration = this.duration
63 let delay = this.delay
64 if (time >= delay) {
65 time = Math.min(time, this.totalElapsed) - delay //never go past final value
66 let progress = (time % duration) / duration
67 if (progress === 0 && time !== 0) progress = 1
68 progress = this.easing(progress)
69 if (this.direction === 'reverse' || (this.direction === 'alternate' && Math.ceil(time / duration) % 2 === 0)) {
70 progress = 1 - progress
71 }
72 this.callback(this.interpolate(this.fromValue, this.toValue, progress))
73 }
74 }
75
76 /**
77 * Like `gotoElapsedTime` but goes to the very end of the tween.

Callers 7

gotoEndMethod · 0.95
_syncTweensMethod · 0.45
_tickMethod · 0.45
MultiTween.test.jsFile · 0.45
testTimeFunction · 0.45
Tween.test.jsFile · 0.45

Calls

no outgoing calls

Tested by 1

testTimeFunction · 0.36