Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
20 lines
696 B
Plaintext
20 lines
696 B
Plaintext
import { millisecondsToSeconds } from 'motion-utils';
|
|
import { calcGeneratorDuration, maxGeneratorDuration } from './calc-duration.mjs';
|
|
|
|
/**
|
|
* Create a progress => progress easing function from a generator.
|
|
*/
|
|
function createGeneratorEasing(options, scale = 100, createGenerator) {
|
|
const generator = createGenerator({ ...options, keyframes: [0, scale] });
|
|
const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
|
|
return {
|
|
type: "keyframes",
|
|
ease: (progress) => {
|
|
return generator.next(duration * progress).value / scale;
|
|
},
|
|
duration: millisecondsToSeconds(duration),
|
|
};
|
|
}
|
|
|
|
export { createGeneratorEasing };
|