Last active
March 24, 2020 15:02
-
-
Save lin/1f0a69bd349251260cdbbf4dfc9f0dd1 to your computer and use it in GitHub Desktop.
Basics of Animation
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
render () { | |
// how much progress is it? | |
// from 0 to 1 | |
let progress = time / duration | |
// apply ease function to the progress | |
// lots of action is actually based on ease function | |
// the ease function works like affine transformation matrix | |
// it can make all kinds of simple transformation to the tween | |
let ratio = ease(progress) | |
// the value that will be fed into dom | |
let value = start + ratio * change | |
// set property value of the target | |
setTargetPropertyValue(target, property, value) | |
// render loop | |
requestAnimationFrame(render) | |
} | |
render() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment