@@ -97,8 +97,9 @@ export class Timeline extends Array<Tween>
9797 * @method PIXI.animate.Timeline#addKeyframe
9898 * @param {Object } properties The properties to set.
9999 * @param {int } startFrame The starting frame index.
100+ * @param {int } [duration = 0] The number of frames to hold beyond startFrame (0 is single frame)
100101 */
101- public addKeyframe ( properties : TweenProps , startFrame : number ) : void
102+ public addKeyframe ( properties : TweenProps , startFrame : number , duration = 0 ) : void
102103 {
103104 // see if we need to go back in and insert properties
104105 if ( this . length && this [ this . length - 1 ] . startFrame >= startFrame )
@@ -130,7 +131,7 @@ export class Timeline extends Array<Tween>
130131 prev . endFrame = startFrame - 1 ;
131132 const startProps = Object . assign ( { } , prev . endProps , properties ) ;
132133 // create the new Tween and add it to the list
133- const tween = new Tween ( this . target , startProps , null , startFrame , 0 ) ;
134+ const tween = new Tween ( this . target , startProps , null , startFrame , duration ) ;
134135
135136 this . splice ( i , 0 , tween ) ;
136137 // go through any later keyframes to update them with our inserted props
@@ -148,7 +149,7 @@ export class Timeline extends Array<Tween>
148149 {
149150 const startProps = Object . assign ( { } , prev . endProps , properties ) ;
150151 // create the new Tween and add it to the list
151- const tween = new Tween ( this . target , startProps , null , startFrame , 0 ) ;
152+ const tween = new Tween ( this . target , startProps , null , startFrame , duration ) ;
152153
153154 this . splice ( i , 0 , tween ) ;
154155
@@ -171,7 +172,7 @@ export class Timeline extends Array<Tween>
171172 this . extendLastFrame ( startFrame - 1 ) ;
172173 const startProps = Object . assign ( { } , this . _currentProps , properties ) ;
173174 // create the new Tween and add it to the list
174- const tween = new Tween ( this . target , startProps , null , startFrame , 0 ) ;
175+ const tween = new Tween ( this . target , startProps , null , startFrame , duration ) ;
175176
176177 this . push ( tween ) ;
177178 Object . assign ( this . _currentProps , tween . endProps ) ;
@@ -194,13 +195,14 @@ export class Timeline extends Array<Tween>
194195 if ( prevTween . isTweenlessFrame )
195196 {
196197 prevTween . endFrame = endFrame ;
198+ prevTween . duration = endFrame - prevTween . startFrame ;
197199 }
198200 else
199201 {
200202 this . addKeyframe (
201203 this . _currentProps ,
202204 prevTween . endFrame + 1 ,
203- // endFrame - prevTween.endFrame + 1
205+ endFrame - ( prevTween . endFrame + 1 ) ,
204206 ) ;
205207 }
206208 }
0 commit comments