1

Since I installed Adblock Plus for firefox (Add-ons to block advertisement), every animation powered by scriptaculous doesn't work anymore (not only on my website).

Now that I know it, I'm looking for a way to check if a javascript function was not completed (like the one that I call for my scriptaculous animations).

<script type="text/javascript">

function scriptaculous(){

  new Effect.Morph("thumb_id", { style: "height:300px;", duration: 0.8 });

}

function enlarge_thumbnail(){

  scriptaculous();

// if( scriptaculous() was not completed ){

   document.getElementById("thumb_id").style.height = "300px";

// }

}

</script>

The real problem is that I can't only call the both of them because the first one bug and prevent the second one to load. Anyone knows how to deal with that??

4

1 回答 1

0

每当任何效果启动等时,它们都会添加到全局效果队列中,因此您可以检查队列是否存在以及队列中有多少效果。

if(Effect.Queues.get('global').effects.length == 0)
{
    //do something else

}

afterFinish此外,因为效果方法将立即返回,除非您像这样使用回调,否则您不会确切知道效果何时完成

new Effect.Morph("thumb_id",
                        { 
                         style: "height:300px;", 
                         duration: 0.8, 
                         afterFinish: function(effect){
                           //do other things when the effect is finished
                           //the callback is passed the effect object
                           //and the element it is working on is at effect.element
                         } });
于 2013-06-07T00:54:21.353 回答