getting "afterimages" when moving layers in Firefox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raylaur
    New Member
    • Mar 2007
    • 3

    getting "afterimages" when moving layers in Firefox

    I'm using a javascript "slide" function to move a <div> layer in 10 pixel increments from one location on a page to another. The layer contains a GIF image. It's basically a side panel that flies out when you click a button. The button is an invisible GIF with an anchor that calls slide() onClick.

    The animation works fine in IE but in Firefox I'm getting a series of afterimages as the function moves the layer to the goal. The image is painted in the new position each time but the previous position is also shown and doesn't disappear right away. The movement looks jumpy. It also runs very slowly compared to IE.

    Has anyone had this problem and is there a workaround for fix for this?

    Code:
    <html> 
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" > 
    <title>cn_shell</title> 
    
    <script language="JavaScript" type="text/JavaScript"> 
    
    <!-- These are vars used in the Slide function--> 
    var layername, xgoal, xhop, delay=5; 
    
    <!-- This function handles browser syntax differences--> 
    function makeName(layerID) { 
    if (navigator.appName=="Mozilla") 
    { refname = eval("document." + layerID) } 
    else 
    { refname = eval("document.all." + layerID + ".style") } 
    return refname 
    } 
    
    <!--The slide function moves the object--> 
    function slide() { 
    if ((parseInt(layername.left) != xgoal)) 
    { layername.left = parseInt(layername.left) + xhop; 
    window.setTimeout("slide()", delay) } 
    } 
    </script> 
    
    </head> 
    <body> 
    <!--button layer needs to be above tab layers **************************************************************** --> 
    <div id="buttons" style="position:absolute; width:60px; height:488px; z-index:30; left: 340px; top: 82px;"> 
    <div id="bTab1Out" style="position:absolute; width:16px; height:100px; z-index:31; left: 3px; top: 7px; background-color: #99CCCC; layer-background-color: #99CCCC; border: 1px;"> <a href="#" OnClick="layername=makeName('tab1');xhop=-10; xgoal=410; slide()"> <img src= "emptyButton.gif" width="16" height="100" border="0" ></a> </div> 
    <div id="bTab2Out" style="position:absolute; width:16px; height:60px; z-index:31; left: 3px; top: 127px; background-color: #99CCCC; layer-background-color: #99CCCC; border: 1px;"> <a href="#" OnClick="layername=makeName('tab2');xhop=-10; xgoal=410; slide()"> <img src= "emptyButton.gif" width="16" height="60" border="0" ></a> </div> 
    <div id="bTab3Out" style="position:absolute; width:16px; height:50px; z-index:31; left: 3px; top: 211px; background-color: #99CCCC; layer-background-color: #99CCCC; border: 1px;"> <a href="#" OnClick="layername=makeName('tab3');xhop=-10; xgoal=410; slide()"> <img src= "emptyButton.gif" width="16" height="50" border="0" ></a> </div> 
    
    <div id="bTab1In" style="position:absolute; width:16px; height:100px; z-index:31; left: 33px; top: 7px; background-color: #FFCC99; layer-background-color: #FFCC99; border: 1px;"> <a href="#" OnClick="layername=makeName('tab1');xhop=10; xgoal=780; slide()"> <img src= "emptyButton.gif" width="16" height="100" border="0" ></a> </div> 
    <div id="bTab2In" style="position:absolute; width:16px; height:60px; z-index:31; left: 33px; top: 127px; background-color: #FFCC99; layer-background-color: #FFCC99; border: 1px;"> <a href="#" OnClick="layername=makeName('tab2');xhop=10; xgoal=780; slide()"> <img src= "emptyButton.gif" width="16" height="60" border="0" ></a> </div> 
    <div id="bTab3In" style="position:absolute; width:16px; height:50px; z-index:31; left: 33px; top: 211px; background-color: #FFCC99; layer-background-color: #FFCC99; border: 1px;"> <a href="#" OnClick="layername=makeName('tab3');xhop=10; xgoal=780; slide()"> <img src= "emptyButton.gif" width="16" height="50" border="0" ></a> </div> 
    </div> 
    
    <!--TAB 1 START **************************************************************** --> 
    <div id="tab1" style="position:absolute; width:390px; height:488px; z-index:25; left: 780px; top: 82px;"> <img src= "minfo-tab-in.gif" width="390" height="488" name="minfo-tab-in"> 
    <div id="moreInfoContent" style="position:absolute; width:360px; height:480px; z-index:21; left: 25px; top: 5px; overflow: auto; visibility: hidden;">This is more information</div> 
    </div> 
    <!--TAB 1 END **************************************************************** --> 
    <!--TAB 2 START **************************************************************** --> 
    <div id="tab2" style="position:absolute; width:390px; height:488px; z-index:20; left: 780px; top: 82px;"> <img src= "glossary-tab-in.gif" width="390" height="488" name="glossary-tab-in"> 
    <div id="moreInfoContent" style="position:absolute; width:360px; height:480px; z-index:21; left: 25px; top: 5px; overflow: auto; visibility: hidden;">This is a glossary</div> 
    </div> 
    <!--TAB 2 END **************************************************************** --> 
    <!--TAB 3 START **************************************************************** --> 
    <div id="tab3" style="position:absolute; width:390px; height:488px; z-index:15; left: 780px; top: 82px;"> <img src= "help-tab-in.gif" width="390" height="488" name="help-tab-in"> 
    <div id="moreInfoContent" style="position:absolute; width:360px; height:480px; z-index:21; left: 25px; top: 5px; overflow: auto; visibility: hidden;">This is help information.</div> 
    </div> 
    <!--TAB 3 END **************************************************************** --> 
    
    
    </body> 
    </html>
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    First things first. Your <html> tag is in the wrong position. It needs to come after the doctype. But moving it there means it doesn't work at all, at least in Firefox.

    In addition, you are using the id "moreInfoConten t" more than once. You can only use an id name once on a page.

    Try fixing those two errors while I run to the store.

    Comment

    • raylaur
      New Member
      • Mar 2007
      • 3

      #3
      Originally posted by drhowarddrfine
      First things first. Your <html> tag is in the wrong position. It needs to come after the doctype. But moving it there means it doesn't work at all, at least in Firefox.

      In addition, you are using the id "moreInfoConten t" more than once. You can only use an id name once on a page.

      Try fixing those two errors while I run to the store.
      Thanks for taking a look. As you said, placing the <html> tag after the doctype doesn't work in Firefox. But I did correct the error of multiple ID names.

      What''s happening is I'm getting repeating images. You might not see this unless you link the GIF images. I can send these if you need. It seems that the browser is not refreshing after each position change. The movement looks jumpy. When I resize the browser window slightly the repeated images disappear.

      Code:
      <html> 
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
      "http://www.w3.org/TR/html4/loose.dtd"> 
      
      <head> 
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" > 
      <title>cn_shell</title> 
      
      <script language="JavaScript" type="text/JavaScript"> 
      
      <!-- These are vars used in the Slide function--> 
      var layername, xgoal, xhop, delay=5; 
      
      <!-- This function handles browser syntax differences--> 
      function makeName(layerID) { 
      if (navigator.appName=="Mozilla") 
      { refname = eval("document." + layerID) } 
      else 
      { refname = eval("document.all." + layerID + ".style") } 
      return refname 
      } 
      
      <!--The slide function moves the object--> 
      function slide() { 
      if ((parseInt(layername.left) != xgoal)) 
      { layername.left = parseInt(layername.left) + xhop; 
      window.setTimeout("slide()", delay) } 
      } 
      </script> 
      
      </head> 
      <body> 
      <!--button layer needs to be above tab layers **************************************************  ************** --> 
      <div id="buttons" style="position:absolute; width:60px; height:488px; z-index:30; left: 340px; top: 82px;"> 
      <div id="bTab1Out" style="position:absolute; width:16px; height:100px; z-index:31; left: 3px; top: 7px; background-color: #99CCCC; layer-background-color: #99CCCC; border: 1px;"> <a href="#" OnClick="layername=makeName('tab1');xhop=-10; xgoal=410; slide()"> <img src= "emptyButton.gif" width="16" height="100" border="0" ></a> </div> 
      <div id="bTab2Out" style="position:absolute; width:16px; height:60px; z-index:31; left: 3px; top: 127px; background-color: #99CCCC; layer-background-color: #99CCCC; border: 1px;"> <a href="#" OnClick="layername=makeName('tab2');xhop=-10; xgoal=410; slide()"> <img src= "emptyButton.gif" width="16" height="60" border="0" ></a> </div> 
      <div id="bTab3Out" style="position:absolute; width:16px; height:50px; z-index:31; left: 3px; top: 211px; background-color: #99CCCC; layer-background-color: #99CCCC; border: 1px;"> <a href="#" OnClick="layername=makeName('tab3');xhop=-10; xgoal=410; slide()"> <img src= "emptyButton.gif" width="16" height="50" border="0" ></a> </div> 
      
      <div id="bTab1In" style="position:absolute; width:16px; height:100px; z-index:31; left: 33px; top: 7px; background-color: #FFCC99; layer-background-color: #FFCC99; border: 1px;"> <a href="#" OnClick="layername=makeName('tab1');xhop=10; xgoal=780; slide()"> <img src= "emptyButton.gif" width="16" height="100" border="0" ></a> </div> 
      <div id="bTab2In" style="position:absolute; width:16px; height:60px; z-index:31; left: 33px; top: 127px; background-color: #FFCC99; layer-background-color: #FFCC99; border: 1px;"> <a href="#" OnClick="layername=makeName('tab2');xhop=10; xgoal=780; slide()"> <img src= "emptyButton.gif" width="16" height="60" border="0" ></a> </div> 
      <div id="bTab3In" style="position:absolute; width:16px; height:50px; z-index:31; left: 33px; top: 211px; background-color: #FFCC99; layer-background-color: #FFCC99; border: 1px;"> <a href="#" OnClick="layername=makeName('tab3');xhop=10; xgoal=780; slide()"> <img src= "emptyButton.gif" width="16" height="50" border="0" ></a> </div> 
      </div> 
      
      <!--TAB 1 START **************************************************  ************** --> 
      <div id="tab1" style="position:absolute; width:390px; height:488px; z-index:25; left: 780px; top: 82px;"> <img src= "minfo-tab-in.gif" width="390" height="488" name="minfo-tab-in"> 
      <div id="moreInfoContent" style="position:absolute; width:360px; height:480px; z-index:21; left: 25px; top: 5px; overflow: auto; visibility: hidden;">This is more information</div> 
      </div> 
      <!--TAB 1 END **************************************************  ************** --> 
      <!--TAB 2 START **************************************************  ************** --> 
      <div id="tab2" style="position:absolute; width:390px; height:488px; z-index:20; left: 780px; top: 82px;"> <img src= "glossary-tab-in.gif" width="390" height="488" name="glossary-tab-in"> 
      <div id="glossaryContent" style="position:absolute; width:360px; height:480px; z-index:21; left: 25px; top: 5px; overflow: auto; visibility: hidden;">This is a glossary</div> 
      </div> 
      <!--TAB 2 END **************************************************  ************** --> 
      <!--TAB 3 START **************************************************  ************** --> 
      <div id="tab3" style="position:absolute; width:390px; height:488px; z-index:15; left: 780px; top: 82px;"> <img src= "help-tab-in.gif" width="390" height="488" name="help-tab-in"> 
      <div id="helpContent" style="position:absolute; width:360px; height:480px; z-index:21; left: 25px; top: 5px; overflow: auto; visibility: hidden;">This is help information.</div> 
      </div> 
      <!--TAB 3 END **************************************************  ************** --> 
      
      
      </body> 
      </html>

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        The <html> tag needs to be after the doctype in any case. I think this should actually be in the javascript board but OnClick needs to be all lower case. I'm using Firefox but on FreeBSD so I don't know if it matters but with those two changes it works and looked pretty smooth to me.

        Comment

        • raylaur
          New Member
          • Mar 2007
          • 3

          #5
          Wish I could say the same. But thanks for checking anyway.

          Comment

          • AricC
            Recognized Expert Top Contributor
            • Oct 2006
            • 1885

            #6
            Originally posted by raylaur
            Wish I could say the same. But thanks for checking anyway.
            What browser isn't this working with? FF should run the same regardless of OS.

            Comment

            • drhowarddrfine
              Recognized Expert Expert
              • Sep 2006
              • 7434

              #7
              Then I think it might be time to move this to the js forum.

              Comment

              • AricC
                Recognized Expert Top Contributor
                • Oct 2006
                • 1885

                #8
                Originally posted by drhowarddrfine
                Then I think it might be time to move this to the js forum.
                It didn't work for me in IE6 or FF on Win XP Pro 64, actually are you sure that navigator.appNa me == "Mozilla" is valid? Change Mozilla to Netscape. Running out the door I'll test that in a bit when I get back.

                Comment

                Working...