jquery - 如何stop() jcarousel滚动动画

标签 jquery jcarousel

我已经使用外部控件设置了 jcarousel。当我将鼠标悬停在“控件”列表中的链接上时,轮播会滚动到相应的图像。

到目前为止,一切正常,但是当我将鼠标悬停在不同的“控件”链接上时,它会卡在第一个链接上并等待滚动动画完成。

// SCROLL TO LINK
$('#controls a').on('mouseover',function() {
var opt = $('#controls a').index(this)+1; 
carousel.scroll($.jcarousel.intval(opt)); 
}); 

我不确定,但我想我必须停止“鼠标悬停”上运行的滚动动画才能解决这个问题。

我尝试了这些行(不起作用):

carousel.stop(true);

和:

carousel.scroll.stop(true);

有人可以帮我解决这个问题吗?可能有一个简单的解决方案,但我对 jQuery 或一般编程没有经验。

最佳答案

遇到同样的问题。找到了非常简单的解决方案。 将其放入“jquery.jcarousel.js”

/**
 * Stop animates the carousel, jump To End (animate Slide).
 *
 * @method animate
 * @return undefined
*/
stopAnimate: function() {
this.list.stop(true,true,true);
},

在此之后

 /**
 * Animates the carousel to a certain position.
 *
 * @method animate
 * @return undefined
 * @param p {Number} Position to scroll to.
 * @param a {Boolean} Flag indicating whether to perform animation.
 */
animate: function(p, a) {
    -/-/-/-/(several strings)
},

我的//滚动到链接//看起来像(我有附加自动滚动)

$('#controls a').hover(function() {
        var opt = $("#controls a").index(this) + 1;
        carousel.scroll(opt);
        carousel.stopAuto();//autoScroll Stop
    }, function() {
        carousel.stopAnimate(); //! here is located our function
        carousel.startAuto();//autoScroll Start
    });

也许有人觉得它有用!

关于jquery - 如何stop() jcarousel滚动动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12722974/

相关文章:

jquery - jCarousel 使用 jQuery 为轮播设置动画

javascript - 一种格式化长压缩 JavaScript 代码的工具 (jCarousel)

javascript - 为多个元素创建同步动画

javascript - Bootstrap 响应在包含 Viewport meta 后不起作用

javascript - JS slider 计数器不工作...需要找到一种方法让它正常工作

jquery - 在特定位置创建img

javascript - 定位从 PHP 传递的特定元素 ID

javascript - 我的 jCarousel 随机地只在其中一个列表项中滚动一半

javascript - 如何通过外部控件/事件启动/停止 jCarousel

jquery - jCarousel + jQuery UI 选项卡问题 : Hidden panel list width is being incorrectly calculated