Jump to content

Updating shared ticker in inactive tab


jiroler
 Share

Recommended Posts

I have a problem with AnimatedSprite in inactive tab. If you leave the tab after the start of the animation (goToAndPlay()), the event onComplete() does not work. Why is this happening?

I try update shared ticker by setInterval()

this.app = new PIXI.Application({
    //...
    sharedTicker : true,
    autoStart: false,
    //...
});

this.app.ticker.start();
this.tickerInterval = null;

// Events:
//...
this.emitter.on('window-focus', () => {
    this.tickerInterval && clearInterval(this.tickerInterval);
    this.app.ticker.start()
}).on('window-blur', function(){
    this.app.ticker.stop();
    this.tickerInterval = setInterval(function(){
        this.app.ticker.update(new Date().getTime());
        this.app.renderer.render(this.app.stage);
    }, 30);
});

 

Link to comment
Share on other sites

Another relevant place: https://github.com/pixijs/pixi.js/blob/dev/packages/ticker/src/Ticker.js#L390

Also I dont recomment setting up that small interval on blur. 400ms shoulkd be enough, and i dont think we need to render stage. maybe only call updateTransform()  on it. Dont forget temp parent or ask updateTransform on stage children but not on stage itself or it'll crash with nullpointer. Yeah, i know, its stupid.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...