View Single Post
Old 10-17-2013, 05:02 AM   #1
fredpeterson543
Registered User
 
Join Date: Jul 2013
Posts: 173
DHTML animation question?

I wonder if anyone could help me with this simple DHTML movement question. I am trying to get my ball to go right then left in a smooth manner. I can get it to go right fine, but it jerks back to the left. I have tried all sorts of variables but it doesn't seem to want to work. The code is this:

<html>
<head>

<script language = "javascript">
dir = 0

function move() {
if(dir == 0) {
ball.style.pixelLeft +=3

if(ball.style.pixelLeft>=400)
ball.style.pixelLeft =-3
}

else if(ball.style.pixelLeft<20) {
ball.style.pixelLeft +=3}


setTimeout("move()", 30)
}
</script>

</head>


<body onload="move()">
<img src = "ball.jpg" style="position: absolute; left: 30px; width: 100px; height: 100px" id="ball">

</body>
</html>

give me your advice please
Web Designing Companies in Delhi | Wedding Planners in Delhi | Event Management Companies in Delhi

Last edited by fredpeterson543; 02-07-2016 at 01:19 AM..
fredpeterson543 is offline   Reply With Quote