在重新附加JQuery中的插件之前,我是否需要PAUSE / RESUME ANIMATION的销毁功能?

时间:2011-02-25 09:09:40

标签: jquery animation

在我的上一个问题中:

The way to stop and continue animation while mouseover and mouseout in JQuery

我在文字框的动画中使用了PAUSE / RESUME ANIMATION (ANIMATE)插件。但是我遇到了一个问题:

因为我的字幕文字是动态的。例如:

<div class="marquee">the dynamic marquee text here</div>

<!--and switch marquee text when you click the li-->
<ul>
  <li> the first marquee text contest here</li>
  <li> the second....</li>
  <li> much more below </li>
</ul>

所以,在multi-times点击li切换选框内容后,FF提示我插件正忙着工作,我应该停止脚本。我想,插件在重新绑定时应该有一个destroy函数。

插件的用法,它有三个功能:

$(document).ready(function () {

    $(".moveDiv")
    .mouseover(function () { $(this).pauseAnimation(); })
    .mouseout(function () { $(this).resumeAnimation(); })
    .startAnimation({ "margin-left": 2000 }, 20000, 'linear');

});

FF提示忙的代码:

jQuery.fn.startAnimation = function(  params, duration, easing, callback ) {
    jQuery(this).animate( params, duration, easing, callback );
    var data = { target:this.get(0), params: params, duration: duration, easing: easing, callback: callback,
                startTime: new Date().getTime(), timePlayed: 0, timeRemaining: 0 };
    if( !jQuery.pauseableAnimations ) {
        jQuery.extend({ pauseableAnimations: new Array( data ) });
    } else {
             // FF prompt the for loop is busy and below 
        for( var i in jQuery.pauseableAnimations ) {
            if( jQuery.pauseableAnimations[i].target == this.get(0) ) {
                //  busy here, too
                            jQuery.pauseableAnimations[i] = data;
            } else {
                jQuery.pauseableAnimations.push( data );
            };
        };
    };
};

非常感谢!!

0 个答案:

没有答案