pixijs / gif

Plugin to support playback of animated GIF images in PixiJS.
https://pixijs.io/gif/docs/
MIT License
37 stars 5 forks source link

playback from percent of page loaded #4

Closed locksy closed 2 years ago

locksy commented 2 years ago

I want to control the playback of a gif, where the frame corresponds to the percentage of the base page that is loaded. In essence, a loading screen. Is this possible?

bigtimebuddy commented 2 years ago

Yes, you can do something like this:

gif.currentFrame = Math.round(percentage * (gif.totalFrames - 1));

Documentation has more information about properties: https://pixijs.io/gif/docs/PIXI.gif.AnimatedGIF.html