Open lucasdinonolte opened 1 year ago
Name | Link |
---|---|
Latest commit | 564f6e537c5653aa26efc893f2c7451683040dfe |
Latest deploy log | https://app.netlify.com/sites/dsi-logo-maker/deploys/64649e3d1d53df0008230470 |
Deploy Preview | https://deploy-preview-177--dsi-logo-maker.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
This is a little something that was in the back of my head for some time – but it's only for after the new animation API is in.
Context
I've found myself copy & pasting over code to handle non-linear interpolation (aka easing) for animation over and over again. So I had this idea it could be cool if mechanic provided a simple way to use the most common easing functions without having to re-code them yourself.
What this does
This adds a
@mechanic-design/transition
package that exposes a generic interpolation helper to the user. It also comes with pre-built versions of the most commonly used easing functions for quick access. But users’ can also bring their own easing function if they wanted to.The transition function is setup as a curried function, to encourage a clean usage based on animation lifecycle events—the transition should be set up when setting up your design function and then in the draw loop you only pull values from it.
Examples
The most basic example, animating a rectangle’s position:
Using a custom easing function:
The transition helper only works with numerical values. You could however still use it to interpolate non numerical values (like color), by using the transition helper to generate the easing curve for you and then passing a normalized transition value to a specific interpolation function. The example shows this