@@ -197,14 +197,15 @@ p.setRatio = function (ratio, endData, i) {
197197p . render = function ( ) {
198198 this . defaultData . forEach ( ( item , i ) => {
199199 let initTime = item . initTime ;
200+ const duration = parseFloat ( item . duration . toFixed ( 10 ) ) ;
200201 // 处理 yoyo 和 repeat; yoyo 是在时间轴上的, 并不是倒放
201202 let repeatNum = Math . ceil ( ( this . progressTime - initTime ) /
202- ( item . duration + item . repeatDelay ) ) - 1 ;
203+ ( duration + item . repeatDelay ) ) - 1 ;
203204 repeatNum = repeatNum < 0 ? 0 : repeatNum ;
204205 // repeatNum = this.progressTime === 0 ? repeatNum + 1 : repeatNum;
205206 if ( item . repeat ) {
206207 if ( item . repeat || item . repeat <= repeatNum ) {
207- initTime = initTime + repeatNum * ( item . duration + item . repeatDelay ) ;
208+ initTime = initTime + repeatNum * ( duration + item . repeatDelay ) ;
208209 }
209210 }
210211 // 精度损失,只取小数点后10位。
@@ -217,8 +218,8 @@ p.render = function () {
217218 if ( ! this . register ) {
218219 this . register = true ;
219220 // 在开始跳帧时。。[{x:100,type:'from'},{y:300}],跳过了from时, moment = 600 => 需要把from合回来
220- const st = progressTime / ( item . duration + fromDelay ) > 1 ? 1 :
221- easingTypes [ item . ease ] ( progressTime < 0 ? 0 : progressTime , 0 , 1 , item . duration ) ;
221+ const st = progressTime / ( duration + fromDelay ) > 1 ? 1 :
222+ easingTypes [ item . ease ] ( progressTime < 0 ? 0 : progressTime , 0 , 1 , duration ) ;
222223 this . setRatio ( item . type === 'from' ? 1 - st : st , item , i ) ;
223224 return ;
224225 }
@@ -231,19 +232,19 @@ p.render = function () {
231232 }
232233 if ( progressTime < 0 && progressTime + fromDelay > - this . perFrame ) {
233234 this . setRatio ( item . type === 'from' ? 1 : 0 , item , i ) ;
234- } else if ( progressTime >= item . duration && item . mode !== 'onComplete' ) {
235+ } else if ( progressTime >= duration && item . mode !== 'onComplete' ) {
235236 this . setRatio ( item . type === 'from' || ( repeatNum % 2 && item . yoyo ) ? 0 : 1 , item , i ) ;
236237 if ( item . mode !== 'reset' ) {
237238 item . onComplete ( ) ;
238239 }
239240 item . mode = 'onComplete' ;
240- } else if ( progressTime >= 0 && progressTime < item . duration ) {
241+ } else if ( progressTime >= 0 && progressTime < duration ) {
241242 item . mode = progressTime < this . perFrame ? 'onStart' : 'onUpdate' ;
242243 progressTime = progressTime < 0 ? 0 : progressTime ;
243- progressTime = progressTime > item . duration ? item . duration : progressTime ;
244- let ratio = easingTypes [ item . ease ] ( progressTime , 0 , 1 , item . duration ) ;
244+ progressTime = progressTime > duration ? duration : progressTime ;
245+ let ratio = easingTypes [ item . ease ] ( progressTime , 0 , 1 , duration ) ;
245246 if ( item . yoyo && repeatNum % 2 || item . type === 'from' ) {
246- ratio = easingTypes [ item . ease ] ( progressTime , 1 , 0 , item . duration ) ;
247+ ratio = easingTypes [ item . ease ] ( progressTime , 1 , 0 , duration ) ;
247248 }
248249 this . setRatio ( ratio , item , i ) ;
249250 if ( progressTime <= this . perFrame ) {
@@ -252,7 +253,7 @@ p.render = function () {
252253 item . onUpdate ( ratio ) ;
253254 }
254255 }
255- if ( progressTime >= 0 && progressTime < item . duration + this . perFrame ) {
256+ if ( progressTime >= 0 && progressTime < duration + this . perFrame ) {
256257 this . onChange ( {
257258 moment : this . progressTime ,
258259 item,
0 commit comments