Skip to main content

updateEffectKeyframes()v4.0.528

Adds, removes, moves, or configures keyframes on an effect property.

warning

Draft API: This API is experimental and may change.

update-effect-keyframes.ts
import {updateEffectKeyframes, type CodemodProject, type EffectReference} from '@remotion/codemods'; declare const project: CodemodProject; declare const effect: EffectReference; const result = await updateEffectKeyframes({ project, effect, updates: [ {key: 'radius', operation: {type: 'add', frame: 0, value: 0}}, {key: 'radius', operation: {type: 'add', frame: 30, value: 12}}, ], }); console.log(result);

The effect must be a call in an inline effects array with a supported configuration. Required interpolation imports and frame hooks are added. Frame coordinates belong to the interpolation expression's local frame clock.

Creating an animation that needs a new useCurrentFrame() hook requires an enclosing function. Existing supported interpolation expressions can be edited outside functions. Static effect prop edits outside functions remain supported by updateEffectProps().

Options​

project​

An in-memory CodemodProject. The input project is not mutated.

effect​

An EffectReference: filePath, nodePath, and a zero-based effectIndex in the node's inline effects array.

updates​

An array of {key, operation} objects, applied in order. Node prop keys may use paths such as style.opacity. Effect keys name configuration properties.

operation​

Use {type: 'add', frame, value} to add or replace a keyframe; {type: 'remove', frame, valueWhenLastKeyframeDeleted} to remove one; {type: 'move', moves: [{fromFrame, toFrame}]} to move keyframes; {type: 'easing', segmentIndex, easing} to change easing; or {type: 'settings', clamping, posterize, output} to change interpolation settings. For settings, pass undefined for unchanged fields. valueWhenLastKeyframeDeleted supplies the static fallback when removing the final keyframe, or null to use the supported default.

schema?​

A Remotion InteractivitySchema for schema-specific defaults and enum variants. By default, no schema-specific behavior is applied.

videoConfig?​

The composition's width, height, fps, and durationInFrames. Supply these to interpret supported expressions using useVideoConfig(). By default, those runtime values are unknown.

Return value​

A promise resolving to an object with the following properties.

changes​

An array of {filePath, previousContents, nextContents} file changes. A null content value indicates a created or deleted file.

nodePathRemappings​

An array of {filePath, oldNodePath, newNodePath} mappings. A null old path indicates an insertion; a null new path indicates removal. Apply these mappings to references from the input project. See node references.

updatedEffect​

The effect reference in the updated project. The node path may change when a frame hook is inserted.

Errors​

Throws or rejects when the target cannot be resolved, the requested edit is unsupported, or an option is invalid. Failed edits leave the input project unchanged.

Compatibility​

BrowsersServersEnvironments
Chrome
Firefox
Safari
Node.js
Bun
Serverless Functions

See also​