www.webdeveloper.com
Results 1 to 2 of 2

Thread: doctype and animation problem

  1. #1
    Join Date
    Aug 2010
    Posts
    1

    Exclamation doctype and animation problem

    Hello I am new to javascript. I have knowledge of Actionscript.

    I am facing a problem regarding doctype.

    I made a simple animation using javascript but it is not showing on firefox when using doctype,( IE, opera works).

    Without doctype it works perfectly on 3of them.

    Please help me..

    my code goes below.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     <script language="javascript" type="text/javascript" src="src/JSTweener.js"></script>
        <script language="javascript" type="text/javascript">
    	var total = 6;
    	var counter=0;
    	var pos;
    	var imgwidth=950;
    
    	function move1() {
    	  	counter = counter+1;
    		if(counter<total){
    		
    		pos = 0-(950*counter);
    		}else{
    		
    		
    		}
    		JSTweener.addTween(container.style, {
                time: 1,
                transition: "easeInOutQuad",
                onComplete: move2,
                left:pos
            });
          }
    	  
    	  function move2(){
    	  alert(container.style.left);
    	  	if(counter==total-1){
    			counter =0;
    			container.style.left=0+'px';
    			
    		}
    	  }
    	  </script>
    <style type="text/css">
    #main{
    position:absolute;
    overflow:hidden;
    width:950px;
    height:300px;
    
    }
    #container{
    	
    	position:absolute;
    	float:left;
    	width:5px;
    	left:0px;
    	
    }
    .myclass{
    	float:left;
    	z-index:0;
    	}
    </style>
    	
    </head>
    
    <body>
    <div id="main">
    <div id="container" onClick="javascript:start()">
    	<div class="myclass"><img src="images/plate1.jpg"></div>
    	<div class="myclass"><img src="images/plate2.jpg"></div>
    	<div class="myclass"><img src="images/plate3.jpg"></div>
    	<div class="myclass"><img src="images/plate4.jpg"></div>
    	<div class="myclass"><img src="images/plate5.jpg"></div>
    	<div class="myclass"><img src="images/plate1.jpg"></div>
    </div>
    </div>
    <script language="javascript" type="text/javascript">
    function start(){
     var container = document.getElementById('container');
     	container.style.width=imgwidth*total+'px';
     move1();
     }
    </script>
    </body>
    </html>

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Can't see exactly without seeing JSTweener.js, but there is an incorrect reference to container. It is a local reference in function start, so unknown in move1 and move2.
    At least 98% of internet users' DNA is identical to that of chimpanzees

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles