0

我找到了一个用于滚动推荐的 jQuery 插件——但是一旦用户将鼠标悬停在文本上,就需要能够停止动画。你能帮助我吗?

/* * jQuery Quovolver v1.0 - http://sandbox.sebnitu.com/jquery/quovolver * * 由 Sebastian Nitu - 版权所有 2009 - 保留所有权利 * */

(函数($){ $.fn.quovolver = 函数(速度,延迟){

    /* Sets default values */
    if (!speed) speed = 500;
    if (!delay) delay = 10000;

    // If "delay" is less than 4 times the "speed", it will break the effect 
    // If that's the case, make "delay" exactly 4 times "speed"
    var quaSpd = (speed*4);
    if (quaSpd > (delay)) delay = quaSpd;

    // Create the variables needed
    var quote = $(this),
        firstQuo = $(this).filter(':first'),
        lastQuo = $(this).filter(':last'),
        wrapElem = '<div id="quote_wrap"></div>';

    // Wrap the quotes
    $(this).wrapAll(wrapElem);

    // Hide all the quotes, then show the first
    $(this).hide();
    $(firstQuo).show();

    // Set the hight of the wrapper
    $(this).parent().css({height: $(firstQuo).height()});       

    // Where the magic happens
    setInterval(function(){

        // Set required hight and element in variables for animation
        if($(lastQuo).is(':visible')) {
            var nextElem = $(firstQuo);
            var wrapHeight = $(nextElem).height();
        } else {
            var nextElem = $(quote).filter(':visible').next();
            var wrapHeight = $(nextElem).height();
        }

        // Fadeout the quote that is currently visible
        $(quote).filter(':visible').fadeOut(speed);

        // Set the wrapper to the hight of the next element, then fade that element in
        setTimeout(function() {
            $(quote).parent().animate({height: wrapHeight}, speed);
        }, speed);

        if($(lastQuo).is(':visible')) {
            setTimeout(function() {
                $(firstQuo).fadeIn(speed*2);
            }, speed*2);

        } else {
            setTimeout(function() {
                $(nextElem).fadeIn(speed);
            }, speed*2);
        }

    }, delay);

};

})(jQuery);

4

1 回答 1

0

你的问题是在 setInterval 中添加悬停暂停吗

?

于 2013-06-03T15:04:28.520 回答