我有几个带有CSS动画的气泡div。使用jQuery,我想在悬停时停止动画,当用户不再悬停时继续运行。
Chrome中的所有东西都运行得很好,但是Firefox决定在暂停它之前先把泡沫弄坏。在暂停之前,它看起来是首先重置了气泡动画。
这是JSFiddle
我用来暂停它的唯一代码是:
// 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();
});
});有人知道我做错了什么或者忽略了什么吗?
发布于 2014-03-22 08:45:46
从您的transitions中删除它覆盖您的动画,并从它的初始位置开始,再次尝试,
CSS
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()中使用
// 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();
});
});https://stackoverflow.com/questions/21729989
复制相似问题