可以加载GIF动画不播放动画?

可以加载GIF动画不播放动画?

问题描述:

我不知道是否有一种方法prevent从实际动画GIF动画,在和LT加载浏览器,IMG> 标记。
我只是希望它显示GIF的第一帧,不播放动画。

I wonder if there is a way to prevent a browser from actually animating an animated gif, loaded in a <img> tag. I just want it to display the first frame of the gif and don't play the animation.

我已经担心无法做到这一点,我要提取的第一帧,它呈现在画布...:/

I already fear that this isn't possible and I have to extract the first frame and render it to a canvas... :/

这是一个有点昂贵的解决方案,但如果你在一个很短的setInterval重置图像SRC它显示为静态例如:

This is kinda an expensive solution, but if you reset image SRC on a very short setInterval it appears as static e.g:

setInterval(function() {
       document.getElementById('img1').src = document.getElementById('img1').src
},1)

演示: http://jsfiddle.net/MEaWP/6/