• Follow me on:

Thursday, December 5, 2019

How to reset animated GIF image?


Recently I was working for a UI, where I was using GIF image for some interaction. On document load GIF image starts animating, when we switch to different tabs and again back to this tab containing the animated gif image, but when I return to this tab the gif "starts" at a point somewhere in the middle.

 I was looking for the solution of restarting the gif animation. Best solution I found is reloading the image by resetting the image "src".   JQuery code for reloading the image with id = #gifImage

<img src="anim.gif" id="gifImage" />

JQuery:
jQuery('#gifImage').removeAttr('src','');

Removing the attribute of the image again displaying the image on action whenever needed will restart the gif from beginning.


  Share Your Solutions

No comments:

Post a Comment

All Rights Reserved Jaydharphics Click To Mail Me (+91 9564 5592 84)