Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bigtimebuddy committed Feb 16, 2024
1 parent 95f857f commit 7cdaf40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h2 class="mb-3">Original GIF</h2>

const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document);
const $view = $('#root');
const $canvas = $('#root');
const $preview = $('#preview');
const $buttons = Array.from($$('button[data-src]'));
const $play = $('#play');
Expand Down Expand Up @@ -104,9 +104,9 @@ <h2 class="mb-3">Original GIF</h2>
function playAnimation(imageName, imagePath) {
clearAnimation();
animation = animations[imageName];
$view.width = animation.width;
$view.height = animation.height;
app.renderer.resize($view.width, $view.height);
$canvas.width = animation.width;
$canvas.height = animation.height;
app.renderer.resize($canvas.width, $canvas.height);
$preview.src = imagePath || imageName;
$slider.max = animation.totalFrames - 1;
currentAnimation = animation;
Expand All @@ -131,9 +131,10 @@ <h2 class="mb-3">Original GIF</h2>
await app.init({
width: 476,
height: 280,
canvas: $view,
canvas: $canvas,
backgroundAlpha: 0,
hello: true,
preference: 'webgl',
});
const resources = await PIXI.Assets.load(sources);
$buttons.forEach($button =>
Expand Down
5 changes: 3 additions & 2 deletions src/AnimatedGIF.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ class AnimatedGIF extends Sprite
{
super(Texture.EMPTY);

// Handle rerenders
this.onRender = () => this.updateFrame();

// Get the options, apply defaults
const { scaleMode, width, height, ...rest } = Object.assign({},
AnimatedGIF.defaultOptions,
Expand Down Expand Up @@ -288,8 +291,6 @@ class AnimatedGIF extends Sprite
{
this.play();
}

this.onRender = () => this.updateFrame();
}

/** Stops the animation. */
Expand Down

0 comments on commit 7cdaf40

Please sign in to comment.