Skip to content

Commit 4f2879e

Browse files
ericenteandrewstart
authored andcommitted
Fix gotoAndStop issue
Fix issue with jumping to a non-keyframed frame following a tween
1 parent 18ab976 commit 4f2879e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/animate/Timeline.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/animate/Tween.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ export class Tween
376376
*/
377377
public endProps: TweenProps;
378378
/**
379-
* duration of tween in frames. For a keyframe with no tweening, the duration will be 0.
379+
* duration of tween in frames. A single-frame keyframe has a duration of 0.
380380
*/
381381
public duration: number;
382382
/**

0 commit comments

Comments
 (0)