Posts

Showing posts with the label Gif

Can You Control GIF Animation With Javascript?

Answer : You can use the libgif library. It allows you to start/stop the gif and control which frame the gif is on. <script type="text/javascript" src="./libgif.js"></script> <img src="./example1_preview.gif" rel:animated_src="./example1.gif" width="360" height="360" rel:auto_play="1" rel:rubbable="1" /> <script type="text/javascript"> $$('img').each(function (img_tag) { if (/.*\.gif/.test(img_tag.src)) { var rub = new SuperGif({ gif: img_tag } ); rub.load(function(){ console.log('oh hey, now the gif is loaded'); }); } }); </script> (most of the code is taken directly from their example) I use x-gif it's pretty cool and easy to setup. From Github: <x-gif src="probably_cats.gif"></x-gif> Where you can add the following as attributes...