For the moment, this repository only has one useful expression: spring-easing.
Other implementations of spring dynamics I have found are incredibly inefficient, bringing my new macbook pro down to its knees. This implements the analytic solution to the energy equations of damped harmonic oscillators, solved for position over time instead of requiring computationally inefficient recursion. For more information about the relevant physics and the analytic solution, see this course outline.
- When the oscillations carry over past the next value change (see example below with
animationSpeed = 0.5
andspringDamping = 0.3
), the value is reset. I believe it would be possible to fix this fairly easily. - The minified version doesn't work.
Simply copy-paste the entire expression wherever a property needs to be springy. Leave keyframe interpolation as "linear".
Example: applying the expression to position keyframes
Result with animationSpeed = 1.2
and springDamping = 1
:
Result with animationSpeed = 1.2
and springDamping = 3
:
Result with animationSpeed = 1.2
and springDamping = 0.3
:
Result with animationSpeed = 0.5
and springDamping = 0.3
: