Jump to content

Animating in javascript


MrAdam

Recommended Posts

(despite it says i know javascript in my sig) I've never really played with animating something before. basically, what I want to do is slowly move an object to a specific point on the page. I've so far come up with the following:

var y;var t;function moveObject(obj) { y = obj.offsetTop; if (y > 50) {  obj.offsetTop = y - 1; } else {  return; }  t = setTimeout("moveObject(obj)",1000)}

i can't see any problems in it, the only thing I could think it would be is the timer... anybody know a soloution to fix it?-ThanksssUPDATE: silly me, you can't change 'offsetTop' directly!

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
×
×
  • Create New...