jQuery滑块不会立即停止
问题描述:
我想知道为什么我的jQuery滑块不会立即停止事件后:mouseover。有一个延迟,有人能帮我解决这个问题吗? 这里有我的代码:https://jsfiddle.net/jrswchkp/1/jQuery滑块不会立即停止
$(function() {
var $clientcarousel = $('#clients-list');
var clients = $clientcarousel.children().length;
var clientwidth = (clients * 400); // 140px width for each client item
$clientcarousel.css('width', clientwidth);
var rotating = true;
var clientspeed = 0;
var seeclients = setInterval(rotateClients, clientspeed);
function rotateClients() {
if (rotating != false) {
var $first = $('#clients-list li:first');
$first.animate({'margin-left': '-220px'}, 5000, "linear", function() {
$first.remove().css({'margin-left': '0px'});
$('#clients-list li:last').after($first);
});
} else {
$('#clients-list li').stop();
}
}
$(document).on({
mouseover: function(){
rotating = false; // turn off rotation when hovering
},
mouseleave: function(){
rotating = true;
}
}, '.clients');
});
我还有一个问题 - 立即开始呢?是否有任何功能允许回滑? –
你必须创建你自己的功能。 JQuery中没有任何东西让你暂停和恢复动画。但有像[这一个]插件(http://tobia.github.io/Pause/)。 –
谢谢!你能给我建议如何将这个应用到我的代码?它看起来像我是js jquery dummy –