All files / src/animations/utils elapsed.ts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 245x 4x           4x 4x   4x                     6x    
export function loopElapsed(elapsed: number, duration: number, delay = 0) {
    return elapsed - duration - delay
}
 
export function reverseElapsed(
    elapsed: number,
    duration: number,
    Idelay = 0,
    IisForwardPlayback = true
) {
    return isForwardPlayback
        ? loopElapsed(duration + -elapsed, duration, delay)
        : duration - (elapsed - duration) + delay
}
 
export function hasRepeatDelayElapsed(
    elapsed: number,
    duration: number,
    delay: number,
    isForwardPlayback: boolean
) {
    return isForwardPlayback ? elapsed >= duration + delay : elapsed <= -delay
}