Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
cwredcross

Cant get TweenMax to work

Recommended Posts

Here's my sample code.  Pretty simple.  Yet it doesn't work on my server.  I don't see a coding problem. Do I need to change a server setting?  Url is www.leadsgopro.com. Please help.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
 
<style>
body{
  background-color: black;
}
html, body, #container {
width:100%; 
height:100%;
}
</style>
 
<script>
TweenMax.to(".logo", 2, {left:600});
</script>
 
</head>
<body> 
 
<div id="container">
<img id="logo" class="logo" src="http://gravatar.com/avatar/5a224f121f96bd037bf6c1c1e2b686fb?s=512" height="150" width="150">
</div>
</body>
</html>
Link to comment
Share on other sites

Hi cwredcross, welcome to the forums!

 

The way you have it, you are telling JavaScript to access an element that does not exists yet. You either use a window.onload event or you have you JavaScript at the bottom of your page.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR...D/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 

<style>
body{
  background-color: black;
}
html, body, #container {
width:100%; 
height:100%;
}
</style>

<script src="http://cdnjs.cloudfl...n.js"></script>

</head>
<body> 

<div id="container">
<img id="logo" class="logo" src="http://gravatar.com/...1e2b686fb?s=512" height="150" width="150">
</div>

<script>
TweenMax.to(".logo", 2, {left:600});
</script>

</body>
</html>
  • Like 3
Link to comment
Share on other sites

yep , Dipscom is right , and you need to set position to absolute too :

.logo{position:absolute;}

, btw you can use x/y property instead of left/top , and have more smooth tween ( use subpixels instead of pixels )

  • Like 2
Link to comment
Share on other sites

Thanks Guys. That makes all the sense in the world. Cant believe I didnt see it. I havent tried it yet, but I will later. Thanks again.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×