Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Javascript Animation Help

Name: Anonymous 2010-12-13 9:05

Javascript

I'm trying to make a picture bounce between 50px x value, to 200 pixels left of the right boundary. (img is 150px wide, so this would work for top/left corner)

Here is my code:

<script>
var y = 0;
var x = 50;
width = document.body.clientWidth;
var stophere = width - 200;

function animate()
{
while (x < stophere)
{
x += 5;
shiftTo(x, y, 2);
}
}

I have other functions that make the animation actually occur, which it does, but only when I don't use the while statement. Am I doing something wrong with determining the width and setting it to a var?

What I'm trying to do:
Picture with top/left corner at (0,50) ---> Translates right until width - 200

In theory this should be easy...javascript fucking sucks

Name: Anonymous 2010-12-13 9:29

How would I even set up a timer that moves it until that certain "stophere" point? I'm basing it off pixels, and different resolutions would fuck up the timer in that case wouldn't they?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List