How can I wait on fade effect?

Discussion in 'JavaScript' started by Sleeping Troll, Jul 29, 2008.

  1. #1
    I am using the following code to fade a marquee,
    
    var objfade=document.getElementById("Marquee"+Btn);
    objfade.filters[0].apply();
    objfade.style.visibility="hidden";
    objfade.filters[0].play();
    
    Code (markup):
    And it works fine, however after the fade I want to remove the marquee,

    document.body.removeChild(objfade);
    Code (markup):
    If I place this statement after the fade code it executes before the fade is done.

    If I create a loop to wait for fade, fade stops.

    The only exception to this is when I put an alert() in the loop then the fade continues while the alert is displayed. Is there anything else that I could put in loop that would have the same effect? Or is there an event generated by the fade that I could use to trigger function to remove the marquee?
     
    Sleeping Troll, Jul 29, 2008 IP
  2. VishalVasani

    VishalVasani Peon

    Messages:
    560
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello,

    Below URL May help U?

    http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm

    use setTimeout in your script.
     
    VishalVasani, Jul 29, 2008 IP
  3. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah, timeout won't work, in fact nothing will! Javascript is single threaded. If you do anything with Javascript all other processes are suspended, however I did find a solution. Do an AJAX call! In the code for the AJAX call I include the fade effect (I needed to do this call to update a file anyway). while the page is waiting on the xmlHttp Response the fade effect completes, when the xmlHttp Returns I do my deletion! works great!
     
    Sleeping Troll, Jul 30, 2008 IP
  4. sriducati

    sriducati Peon

    Messages:
    287
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i think marque works...
     
    sriducati, Jul 31, 2008 IP