// Format in milliseconds if the total duration is short enough. if (this.getDuration() <= TIME_FORMAT_MAX_DURATION_IN_MS) { return getFormatStr("timeline.timeGraduationLabel", time.toFixed(0)); } // Otherwise format in seconds. return getFormatStr("player.timeLabel", (time / 1000).toFixed(1)); } /** * Return entire animations duration. * * @return {number} duration */ getDuration() { return this.maxEndTime - this.minStartTime; } /** * Return current time of this time scale represents. * * @return {number} */ getCurrentTime() { return this.currentTime - this.minStartTime; } /** * Return end time of given animation. * This time does not include playbackRate and cratedTime. * Also, if the animation has infinite iterations, this returns Infinity. * * @param {object} animation * @return {Numbber} end time */ getEndTime({ state }) { return state.iterationCount ? state.delay + state.duration * state.iterationCount + state.endDelay : Infinity; } } module.exports = TimeScale; PK