Created
June 23, 2010 20:51
-
-
Save cmcculloh/450528 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cQuery.animations = []; | |
setInterval("cQuery.runAnimations()", 100); | |
cQuery.runAnimations = function(){ | |
for(var i=0; i < cQuery.animations.length; i++){ | |
cQuery.animations[i].animation(); | |
} | |
} | |
//add an animation like this: | |
cQuery.animations.push({ | |
"animation":function(){ | |
if(this.currentPosition === undefined){ | |
this.currentPosition = this.startPosition; | |
} | |
//move the element | |
this.currentPosition = this.currentPosition + this.speed; | |
//apply the move | |
this.element.style.top = this.currentPosition - this.element.offsetHeight + "px"; | |
//check to make sure it hasn't moved too far | |
if(this.currentPosition > this.stopPosition | |
&& (this.repeat === "forever" || this.repeat < this.iteration)){ | |
this.currentPosition = this.startPosition; | |
this.element.style.top = this.currentPosition - this.element.offsetHeight + "px"; | |
} | |
}, | |
"speed":speed, | |
"repeat":repeat, | |
"startPosition":startPosition, | |
"stopPosition":stopPosition, | |
"currentPosition":undefined, | |
"element":cQuery.DOMElements[i], | |
"iteration":0 | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment