Skip to content

Instantly share code, notes, and snippets.

@andyshora
Created March 11, 2020 13:09
Show Gist options
  • Save andyshora/2b82bd6d02275bab71d0a2cf5a548b22 to your computer and use it in GitHub Desktop.
Save andyshora/2b82bd6d02275bab71d0a2cf5a548b22 to your computer and use it in GitHub Desktop.
const linearInterpolate = interpolateObject({ val: 0 }, { val: 100 })
console.log(linearInterpolate(0.25))
console.log(linearInterpolate(0.75))
const easeInterpolate = easeFn => (a, b) => {
const i = interpolateObject(a, b)
return t => i(easeFn(t))
}
const curvedInterpolate = easeInterpolate(easeQuadInOut)({ val: 0 }, { val: 100 })
console.log(curvedInterpolate(0.25))
console.log(curvedInterpolate(0.75))
// one liner:
// const easeInterpolate = easeFn => (a, b) => t => interpolateObject(a, b)(easeFn(t))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment