gif动画仅在单击和鼠标按下时播放一次 [英] gif animation play only once onclick and mousedown

查看:360
本文介绍了gif动画仅在单击和鼠标按下时播放一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两张图片:静态图片和动画图片.我正在尝试播放该动画图像,但只能播放一次.之后,它将变为静态之一.

I have two images: static and animated. I am trying to play that animated image but only once. After that, it will change to static one.

我的代码:

$(document).ready(function () {
    $('#targetDIV_three').bind('click mousedown', function () {
        srcToGif2 = "http://demo.pink-squid.co.uk/christmas/s3.gif";
        $("#divthree_three").attr('src', srcToGif2);
    });
});

小提琴: http://jsfiddle.net/squidraj/33Sqd/

目前,它并没有在第一个动画之后停止.

Currently, it is not stopping after the first animation.

带有单个动画循环gif的最新小提琴.

Latest fiddle with single animated loop gif.

http://jsfiddle.net/squidraj/4rC8D/1/

尽管img src正在更改,但现在看不到动画.

Now can't see the animation though the img src is changing.

推荐答案

如果您希望此动画GIF仅播放一次,请在Photoshop中对其进行修改.转到窗口">时间轴",然后选择循环选项(左下角):

If you want this animated GIF to be played only once, modify it in Photoshop. Go to Window > Timeline, then select looping options (bottom left corner):

另存为GIF和Web网页!

Save for web as GIF and voila!

这篇关于gif动画仅在单击和鼠标按下时播放一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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