Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Pause at end of animation #37

Open
AufbeschissenerKunde opened this issue Feb 5, 2016 · 1 comment
Open

Request: Pause at end of animation #37

AufbeschissenerKunde opened this issue Feb 5, 2016 · 1 comment

Comments

@AufbeschissenerKunde
Copy link

Requested option: Pause GIF animation at the end of the loop.

I realize this might be difficult to implement. Having not closely looked at the existing implementations, here are some suggested approaches, which I wouldn't be surprised if they are difficult or flat out impossible:

  1. Override the GIF's internal "max loop" setting and set it to 1. (I wouldn't be surprised though if browsers don't even check this value any more and just assume "infinite looping.")
  2. Detect when the last frame of animation is reached and stop animating.
  3. Figure out the duration of an animation loop (sum of all frames' durations), attach a timer when the animation starts, and stop the animation when the timer ends.
@simonlindholm
Copy link
Owner

This would indeed be nice, but yeah, it's hard. Re the suggestions:

Override the GIF's internal "max loop" setting and set it to 1. (I wouldn't be surprised though if browsers don't even check this value any more and just assume "infinite looping.")

Theoretically doable (I think it's still supported), but it requires hooking all requests (slowing down browsing), and modifying their contents, incrementally, mid-transfer...

Detect when the last frame of animation is reached and stop animating.

The API I'm using in Firefox doesn't let me do this.

Figure out the duration of an animation loop (sum of all frames' durations), attach a timer when the animation starts, and stop the animation when the timer ends.

Doesn't work, because GIFs load incrementally.

Firefox does have an old and crufty flag for precisely this; you can set it for all GIFs via image.animation_mode = "once" in about:config, or programmatically for individual GIFs/images. It doesn't interact very well with this addon, though, because of various brokenness in the implementation and lack of APIs (for instance I can't tell whether an animation has completed, and thus whether to reset animation on hover and such). I would also not be surprised if that functionality was removed during various upcoming animGIF-related refactorings.

Most realistically I think this feature would either require adding new internal APIs to Firefox, or happen as part of adding some mode to the addon where it completely overrides GIF rendering, also allowing e.g. reversing of animations or stepping frame-by-frame. I don't have any plans for that though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants