Searching Open Sourcery

Type to search Open Sourcery.

Motion & Scroll

Frame Engine

Calculates the intermediate states between CSS keyframes, so any property can be scrubbed.

v1.0.1@magic-spells/frame-engine

$ npm i @magic-spells/frame-engine

GitHubnpm

Usage

import FrameEngine from '@magic-spells/frame-engine';

const tween = new FrameEngine({
  0:   { opacity: '0', transform: 'translateX(0px) scale(0.5)' },
  100: { opacity: '1', transform: 'translateX(200px) scale(1)' },
});

// Get styles at 50% through the animation
const styles = tween.getFrame(0.5);
// → { opacity: '0.5', transform: 'translateX(100px) scale(0.75)' }

// Apply to an element
Object.assign(element.style, styles);

About

~5 KB gzipped · zero dependencies

About, features, usage and options are taken from the package README.