Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
play (iterations = -1) {
cancelLoop(this);
if (this._playState === PAUSED) {
// Move the playhead to the correct position in the timeline if resuming
// from a pause
this._loopTimestamp += Tweenable.now() - this._pausedAtTime;
} else {
this._loopTimestamp = Tweenable.now();
}
this._timesToIterate = iterations;
this._playState = PLAYING;
// Start the update loop
tick(this);
fireEvent(this, 'playStateChange');
fireEvent(this, 'play');
return this;
}
play (iterations = -1) {
cancelLoop(this);
if (this._playState === PAUSED) {
// Move the playhead to the correct position in the timeline if resuming
// from a pause
this._loopTimestamp += Tweenable.now() - this._pausedAtTime;
} else {
this._loopTimestamp = Tweenable.now();
}
this._timesToIterate = iterations;
this._playState = PLAYING;
// Start the update loop
tick(this);
fireEvent(this, 'playStateChange');
fireEvent(this, 'play');
return this;
}
pause () {
if (this._playState === PAUSED) {
return this;
}
this._playState = PAUSED;
cancelLoop(this);
this._pausedAtTime = Tweenable.now();
fireEvent(this, 'playStateChange');
fireEvent(this, 'pause');
return this;
}
export const calculateTimeSinceStart = rekapi =>
Tweenable.now() - rekapi._loopTimestamp;
playFrom (millisecond, iterations) {
this.play(iterations);
this._loopTimestamp = Tweenable.now() - millisecond;
this._actors.forEach(
actor => actor._resetFnKeyframesFromMillisecond(millisecond)
);
return this;
}