Search code examples
javascriptjquerycssphotoshopanimated-gif

controlling the time to load and play animated gifs


I have a slide with many animated gifs. Every slide contains an animated gif.

The effect I am trying to achieve is having the animated gifs play according to the timeline I created in photoshop and from the first frame to last when in view.

My issue is the animated gifs will start from the middle of the timeline instead of from the first frame when it is active and in view. I reckon it could be due to the loading time? I have tried increasing the time for the first frame and last frame of each slide but to no avail.

Is there a way to control the time to load and play the animated gifs when it is in view? is it something that needs to be done in javascript or jQuery?


Solution

  • From my point of view, CSS Sprites will give you better support that you wanted in your animation. Most important thing you need is to control over animation.

    As you don't have any control over animated GIFs. You can't start them, you can't stop them, only thing they just do is to animate as soon as they load.

    On the otherhand, with sprites, you can control the animation. Most importantly you can start, stop and react to browser events, pan through the animation.

    As reference you can see Google Doodles which only activates when you only click on them.

    For active reference, you can see the blog which might inspire you to use CSS Sprites.

    https://itnext.io/creating-css-animations-using-sprite-sheet-47e2b7a3793c
    

    Again, it's only opinion. Decisions is yours which one you will use for animation.