Skip to content

Commit

Permalink
Fix animations lag on destroying (#4234)
Browse files Browse the repository at this point in the history
Do something
  • Loading branch information
lucap86 authored and bigtimebuddy committed May 25, 2018
1 parent 0193bd2 commit e9faee4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ticker/src/TickerListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export default class TickerListener
}

// Redirect to the next item
const redirect = this.previous;
const redirect = this.next;

// Remove references
this.next = hard ? null : redirect;
Expand Down
32 changes: 32 additions & 0 deletions packages/ticker/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ describe('PIXI.Ticker', function ()

expect(this.length()).to.equal(length + 1);

expect(listener2.called).to.be.false;
expect(listener1.calledOnce).to.be.true;

shared.update();

expect(listener2.calledOnce).to.be.true;
expect(listener1.calledOnce).to.be.true;

Expand Down Expand Up @@ -370,4 +375,31 @@ describe('PIXI.Ticker', function ()
ticker.add(listener2, null, UPDATE_PRIORITY.LOW);
ticker.start();
});

it('should Ticker call destroyed listener "next" pointer after destroy', function (done)
{
const ticker = new Ticker();

const listener1 = sinon.spy();
const listener2 = sinon.spy(() =>
{
ticker.remove(listener2);
});

const listener3 = sinon.spy(() =>
{
ticker.stop();

expect(listener1.calledOnce).to.be.true;
expect(listener2.calledOnce).to.be.true;
expect(listener3.calledOnce).to.be.true;
done();
});

ticker.add(listener1, null, UPDATE_PRIORITY.HIGH);
ticker.add(listener2, null, UPDATE_PRIORITY.HIGH);
ticker.add(listener3, null, UPDATE_PRIORITY.HIGH);

ticker.start();
});
});

0 comments on commit e9faee4

Please sign in to comment.