可以加载GIF动画不播放动画? [英] Possible to load an animated gif without playing the animation?

查看:178
本文介绍了可以加载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/

这篇关于可以加载GIF动画不播放动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆