Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling GIF Animations with Jquery?

Tags:

jquery

gif

Is this possible? I did some google search but don't seem to find anything. What I want would be kind of like a stop/play function to a gif image.

Would be awesome.

like image 882
Naota Avatar asked Dec 21 '22 12:12

Naota


2 Answers

No. Gifs are played by the browser. There is nothing you can do about it.

The only thing you can do is replace the image with a placeholder. But that will not stop and start the gif at specific locations of the animation, right when you click/toggle.

like image 158
Kissaki Avatar answered Jan 11 '23 14:01

Kissaki


https://stackoverflow.com/a/6017468/873792

Unfortunately, the DOM doesn't expose individual frames of a GIF, so this is done by downloading the GIF (with XMLHttpRequest), parsing it, and drawing it on a canvas.

like image 28
user873792 Avatar answered Jan 11 '23 14:01

user873792