Remotion Animated
repository·main·Indexed 42 days ago
https://github.com/stefanwittwer/remotion-animatedA declarative animation library for Remotion projects that simplifies animation logic using the <Animated /> component. It provides primitives for Fade, Move, Rotate, Scale, and Size transformations, along with a comprehensive Ease namespace for linear, cubic, and custom bezier easing behaviors.
What's inside Remotion Animated
- Remotion Animated is a helper library designed for Remotion that allows you to declaratively specify animations. Instead of manually managing frame counts and interpolation logic, you can use this library to define how properties change over time within your Remotion compositions.
Use Spring animations for natural movement
mainSpring animations are the default animation type in Remotion Animated. They are based on spring physics to create natural-looking motion. If you do not specify any animation options for an animation component, Remotion Animated will automatically apply a default spring animation.Use the Ease collection for standard animations
mainTo use standard timing functions in
Animatedcomponents, import and use theEasecollection fromremotion-animated. This collection provides pre-defined easing functions likeEase.Linear,Ease.QuadraticIn, etc., which are directly compatible with theeaseprop of animation functions.import { Ease } from 'remotion-animated'; // Example usage in an animation function Move({ y: 40, ease: Ease.Linear });Change the rotation origin
mainBy default, theRotateanimation rotates the element from its center because it utilizes the CSStransformproperty. To change the pivot point, apply thetransform-originCSS property to the element being animated via your custom styling.Size vs. Scale: When to use which animation
mainChoosing between
SizeandScaledepends on how you want the children of the animated element to behave:- Use
Sizeif you only want to change the dimensions of the container. The children will reflow or reposition according to the new container size, but their own visual scale remains unchanged. - Use
Scaleif you want to animate the container and the visual scale of its children simultaneously (e.g., making a box and the text inside it appear smaller via a CSStransform).
- Use
Combine multiple Move animations
mainWhen multiple
Moveanimations are provided in theanimationsarray, their translations are cumulative. If an element is moved by oneMoveanimation, subsequentMoveanimations will apply their offsets relative to the resulting position, effectively combining the total translation at the end of the sequence.You can control when each animation starts using the
startproperty (inherited from standard animation options).import { Animated, Move } from 'remotion-animated'; const Example = () => ( <Animated animations={[ Move({ x: 20, y: 80 }), Move({ x: 20, y: -80, start: 20 }), Move({ x: 40, start: 40 }), ]} > <h1>Example text</h1> </Animated> );How Remotion Animated works
mainRemotion Animated allows you to specify animations declaratively within your Remotion JSX. It simplifies animation creation by:
- Moving animation logic directly into JSX using the
<Animated />component. - Providing high-quality default animation settings.
- Enabling easy chaining of multiple timed animations.
Instead of manually calculating frame offsets and interpolation values, you wrap your elements in an
<Animated />component and pass an array of animation instructions.- Moving animation logic directly into JSX using the
Build the documentation for production
mainTo generate the static content for the documentation site, run theyarn buildcommand. The resulting static files will be located in thebuilddirectory and can be hosted on any static content hosting service.yarn buildUse the Size animation to change element dimensions
mainThe
Sizeanimation modifies thewidthorheightof an element's container. This is useful when you want to change the layout dimensions of a container without affecting the visual scale of its children (e.g., text inside a box will not stretch or squash, it will simply reflow as the box grows or shrinks).To use it, pass a
Sizeanimation object into theanimationsarray of the<Animated />component.import { Animated, Size } from 'remotion-animated'; const Example = () => ( <Animated animations={[Size({ width: 300 })]}> <h1>Example text</h1> </Animated> );Use the Rotate animation
mainThe
Rotateanimation rotates an element clockwise along the Z-axis (2D) or along the X and Y axes (3D). To use it, wrap your component in theAnimatedcomponent and pass theRotateanimation to theanimationsprop.Note on 3D Rotation: For
degreesXordegreesYto be visually effective, the parent element must have a CSSperspectiveproperty set.import { Animated, Rotate } from 'remotion-animated'; // 2D Rotation example const Example2D = () => ( <Animated animations={[Rotate({ degrees: 180 })]}> <h1>Example text</h1> </Animated> ); // 3D Rotation example const Example3D = () => ( <div style={{ perspective: '1200px' }}> <Animated animations={[Rotate({ degreesX: 180 })]}> <h1>Example text</h1> </Animated> </div> );Customise spring animation properties
mainYou can fine-tune the behavior of spring animations by providing specific properties to the animation components. These properties allow you to control the physics of the motion (such as stiffness, damping, and mass) to achieve different visual effects.Run the documentation in local development mode
mainTo start a local development server and view the documentation in your browser, use theyarn startcommand. Most changes will reflect live via hot-reloading without requiring a server restart.yarn start