Created
July 11, 2012 01:23
-
-
Save DmitryBaranovskiy/3087311 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function commonCase() { | |
// common case | |
el.animate({x: 10}, 1000, callback); | |
// API | |
var anim = new Anim; | |
anim.timing.iterationDuration = 1000; | |
var f = anim["function"] = new KeyFramesAnimFunction; | |
f.property = "x"; | |
f.frames = new AnimFrameList; | |
var af = new AnimFrame; | |
af.value = 10; | |
af.offset = 1; | |
f.frames.add(af); | |
el.addEventListener("animationEnd", callback, false); | |
var instance = anim.animateLive(el); | |
// cultivated | |
var anim = new Anim(1000); | |
anim.func = new KeyFramesAnimFunction({ | |
1: {x: 10} | |
}); | |
el.addEventListener("animationEnd", callback, false); | |
var instance = anim.animateLive(el); | |
} | |
function keyframes() { | |
el.animate({ | |
.5: {x: 20}, | |
.75: {x: 40}, | |
1: {x:100} | |
}, 1000, callback); | |
// API | |
var anim = new Anim; | |
anim.timing.iterationDuration = 1000; | |
var f = anim["function"] = new KeyFramesAnimFunction; | |
f.property = "x"; | |
f.frames = new AnimFrameList; | |
var af = new AnimFrame; | |
af.value = 20; | |
af.offset = .5; | |
f.frames.add(af); | |
af = new AnimFrame; | |
af.value = 40; | |
af.offset = .75; | |
f.frames.add(af); | |
af = new AnimFrame; | |
af.value = 100; | |
af.offset = 1; | |
f.frames.add(af); | |
el.addEventListener("animationEnd", callback, false); | |
var instance = anim.animateLive(el); | |
} | |
function stopAndStartAnotherOne() { | |
var a = R.Animtion({x: 10}, 1000, callback); | |
el.animate(a); | |
setTimeout(function () { | |
var status = a.status(); | |
el.stop(); | |
el2.animate(a); | |
el2.status(status); | |
}, 500); | |
// API | |
... | |
var instance = anim.animateLive(el); | |
setTimeout(function () { | |
var time = instance.animationTime; | |
instance.cancel(); | |
instance = anim.animateLive(el2); | |
instance.seek(time); | |
}, 500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment