@@ -35,7 +35,6 @@ function defaultData(vars, now) {
3535const timeLine = function ( target , toData , props ) {
3636 this . target = target ;
3737 this . attr = props . attr || 'style' ;
38- this . willChange = props . willChange ;
3938 // 记录总时间;
4039 this . totalTime = 0 ;
4140 // 记录当前时间;
@@ -44,8 +43,6 @@ const timeLine = function (target, toData, props) {
4443 this . defaultData = [ ] ;
4544 // 每个的开始数据;
4645 this . start = { } ;
47- // 记录动画开始;
48- this . onStart = { } ;
4946 // 开始默认的数据;
5047 this . startDefaultData = { } ;
5148 // 动画过程
@@ -159,7 +156,7 @@ p.getAnimStartData = function (item) {
159156 this . computedStyle = this . computedStyle || this . getComputedStyle ( ) ;
160157 Object . keys ( item ) . forEach ( _key => {
161158 if ( _key in _plugin || ( this . attr === 'attr' && ( _key === 'd' || _key === 'points' ) ) ) {
162- start [ _key ] = item [ _key ] . getAnimStart ( this . computedStyle , this . willChange ) ;
159+ start [ _key ] = item [ _key ] . getAnimStart ( this . computedStyle ) ;
163160 return ;
164161 }
165162 if ( this . attr === 'attr' ) {
@@ -282,34 +279,36 @@ p.render = function () {
282279 item . onComplete ( e ) ;
283280 }
284281 item . mode = 'onComplete' ;
285- } else if ( progressTime < this . perFrame ) {
286- ratio = item . ease ( 0 , startData , endData , 1 ) ;
282+ } else if ( progressTime >= 0 && progressTime < duration ) {
283+ ratio = item . ease ( progressTime , startData , endData , duration ) ;
287284 this . setRatio ( ratio , item , i ) ;
288- // 将第一帧作动画开始 start;
289285 if ( ! updateAnim ) {
290- if ( item . repeat && repeatNum > 0 ) {
286+ const startProto = this . start [ i ] ;
287+ if ( ! startProto . _tweenOnEnter ) {
288+ item . mode = 'onStart' ;
289+ startProto . _tweenOnEnter = true ;
290+ item . onStart ( e ) ;
291+ } else if ( item . repeat && repeatNum > 0 && startProto . _tweenRepeatNum !== repeatNum ) {
291292 item . mode = 'onRepeat' ;
292293 item . onRepeat ( { ...e , repeatNum } ) ;
294+ startProto . _tweenRepeatNum = repeatNum ;
293295 } else {
294- item . mode = 'onStart ' ;
295- item . onStart ( e ) ;
296+ item . mode = 'onUpdate ' ;
297+ item . onUpdate ( { ratio , ... e } ) ;
296298 }
297299 }
298- } else if ( progressTime > 0 && progressTime < duration ) {
299- item . mode = 'onUpdate' ;
300- ratio = item . ease ( progressTime , startData , endData , duration ) ;
301- this . setRatio ( ratio , item , i ) ;
302- if ( ! updateAnim ) {
303- item . onUpdate ( { ratio, ...e } ) ;
304- }
305300 }
301+
306302 if ( ! updateAnim ) {
307303 this . onChange ( {
308304 moment : this . progressTime ,
309305 mode : item . mode ,
310306 ...e ,
311307 } ) ;
312308 }
309+ } else if ( progressTime < 0 && this . start [ i ] ) {
310+ delete this . start [ i ] . _tweenOnEnter ;
311+ delete this . start [ i ] . _tweenRepeatNum ;
313312 }
314313 } ) ;
315314} ;
@@ -321,7 +320,6 @@ p.frame = function (moment) {
321320p . resetAnimData = function ( ) {
322321 this . tween = { } ;
323322 this . start = { } ;
324- this . onStart = { } ;
325323} ;
326324
327325p . resetDefaultStyle = function ( ) {
0 commit comments