栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在实际位置/状态上中断/停止CSS3过渡

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在实际位置/状态上中断/停止CSS3过渡

无需深入了解插件,只需

css3animate
使用当前( 计算的 )所需道具的值来重新使用您的方法,并将持续时间设置为0(
在插件中为1,因为您使用
!speed
来使用默认值。

所以在示例中使用

var $animated = $('div');$animated.css3animate({"height": $animated.css('height'), "width": $animated.css('width')}, 1);

会成功的

当然,您应该针对正在使用的当前属性自动执行此操作。如果在启动动画时使用计时器,而在有人使用stop方法时使用计时器,则还可以模拟暂停/继续功能。


更新

您可以将

cssObject
传递给动画的内容存储到
data
元素的,并在它们的停止循环上存储它们以获取当前值。

因此,在您的

animation
方法中,您可以
$obj.data('animationCss', cssObject);
并且在
stop
方法中

stop : function( clearQueue,jumpToEnd ){    return this.each(function(){        var $that = $(this);        var currentCss = {};        var animationCss = $that.data('animationCss');        for (var prop in animationCss) currentCss[prop] = $that.css(prop);        if (jumpToEnd)        { animation($that,currentCss,1, function(){animation($that,animationCss,1)});        }        else        { animation($that,currentCss,1);        }       console.log("stop was called");    });   }


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/416244.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号