首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Firefox中暂停带有Jquery故障的CSS动画

问在Firefox中暂停带有Jquery故障的CSS动画
EN

Stack Overflow用户
提问于 2014-02-12 13:56:53
回答 1查看 372关注 0票数 2

我有几个带有CSS动画的气泡div。使用jQuery,我想在悬停时停止动画,当用户不再悬停时继续运行。

Chrome中的所有东西都运行得很好,但是Firefox决定在暂停它之前先把泡沫弄坏。在暂停之前,它看起来是首先重置了气泡动画。

这是JSFiddle

我用来暂停它的唯一代码是:

代码语言:javascript
复制
// Set the hover and hoverOut
jQuery('.bubble').hover(function () {
    // Pause the CSS animation
    jQuery(this).css('-webkit-animation-play-state', 'paused')
                .css('animation-play-state', 'paused');
}, function () {
    jQuery(this).delay(1000).queue(function (next) {
        // Run the animation again after a delay
        jQuery(this).css('-webkit-animation-play-state', 'running')
                    .css('animation-play-state', 'running')
                    .css({zIndex: jQuery(this).data('oldZindex')
        });
        next();
    });
});

有人知道我做错了什么或者忽略了什么吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-22 08:45:46

从您的transitions中删除它覆盖您的动画,并从它的初始位置开始,再次尝试,

CSS

代码语言:javascript
复制
div.liljon div#bubbles .bubble {
    overflow: hidden;
    position: absolute;
    opacity: 0;
    display: none;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.4);
    /** your remaining background and other properties here */;
}

还可以在类似于key-value pair object的jquery.css()中使用

代码语言:javascript
复制
// Set the hover and hoverOut
jQuery('.bubble').hover(function () {
    // Pause the CSS animation
    jQuery(this).css({'-webkit-animation-play-state': 'paused',
                      'animation-play-state': 'paused'});
}, function () {
    jQuery(this).delay(1000).queue(function (next) {
        // Run the animation again after a delay
        jQuery(this).css({'-webkit-animation-play-state': 'running',
                          'animation-play-state':'running',
                          zIndex: jQuery(this).data('oldZindex')
        });
        next();
    });
});

现场演示

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21729989

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档