import { ITimelineModel } from '../core/types' ; import { _ } from '../utils/constants' ; import { inRange } from '../utils/math' ; import { finish } from './finish' ; import { update } from './update' ; import { IReducer , IReducerContext } from '../core/types' ; export const tick = ( model , delta , _ctx ) => { const duration = model . duration ; const repeat = model . repeat ; const rate = model . rate ; let time = model . time === _ ? ( rate < 0 ? duration : 0 ) : model . time ; let round = model . round || 0 ; const isReversed = rate < 0 ; time += delta * rate ; let iterationEnded = false ; if ( ! inRange ( time , 0 , duration ) ) { model . round = ++ round ; time = isReversed ? 0 : duration ; iterationEnded = true ; if ( model . yoyo ) { model . rate = ( model . rate || 0 ) * - 1 ; } time = model . rate < 0 ? duration : 0 ; } model . time = time ; model . round = round ; if ( iterationEnded && repeat === round ) { finish ( model , _ , _ctx ) ; return ; } update ( model , _ , _ctx ) ; } ;