Frage

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??

War es hilfreich?

Lösung

Whenever any of the Effects start etc they are added to the global Effects queue, so you can check to see of the queue exists and how many effects are in the queue.

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

}

Also because the Effects methods will return immediately you wont exactly know when the effect finished unless you use the afterFinish callback like so

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
                         } });
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top