-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|523|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> Misc


 
Cower
Created : 02 April 2010
Edited : 02 April 2010
System : PSP Vita
Language : Java

Javascript Animation Thingy

Bit of code to handle animating stuff in Javascript.

Bit of forewarning: I don't normally code in Javascript. I don't normally write anything for use in a browser, and this is probably not going to work on the likes of IE6 where shit is just broken. Too bad, so sad, moving on.

This is a single function you call to have something animated over a period of time. You pass it an id (usually an element id, but it could be anything as long as it's a string), a contextual object, a duration, a function, and the time it takes for a frame to complete in milliseconds (I could have made it frames per second, but I was lazy and this is easier).

Every n milliseconds/frame, the function you specified is called with the id, context object, and progress of the animation. Fairly simple, nothing mind-bendingly difficult about it.

If the code is bad, say so and say why, since I'd like to improve it if possible, but who the hell cares?, this is SoCoder.


 

Comments


Friday, 02 April 2010, 17:26
Cower
I decided to just click edit/save a bunch of times on this, and I noticed that every time, the platform/language thing changes to something random. I have no idea why, but it's hilariously stupid.