Skip to content

Instantly share code, notes, and snippets.

@cmcculloh
Created June 23, 2010 20:51
Show Gist options
  • Save cmcculloh/450528 to your computer and use it in GitHub Desktop.
Save cmcculloh/450528 to your computer and use it in GitHub Desktop.
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