Skip to content

Instantly share code, notes, and snippets.

@lin
Last active March 24, 2020 15:02
Show Gist options
  • Save lin/1f0a69bd349251260cdbbf4dfc9f0dd1 to your computer and use it in GitHub Desktop.
Save lin/1f0a69bd349251260cdbbf4dfc9f0dd1 to your computer and use it in GitHub Desktop.
Basics of Animation
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