Skip to main content

getCanvasKeyframeSourceFrame()v4.0.530

Converts a composition frame to the frame clock of a prop's interpolate() expression, in which keyframe operations are expressed.

warning

Experimental API: This package is not stable. Its public API may change without a major version bump.

add-keyframe-at-playhead.ts
export const setOpacityAtPlayhead = (value: number): CanvasKeyframeChange => ({ nodePathInfo, key: 'style.opacity', schema, operation: { type: 'add', frame: getCanvasKeyframeSourceFrame({track, propStatus, frame: playhead}), value, }, });

The keyframes of a nested or trimmed sequence are shifted on the composition timeline, and a playbackRate stretches them. getCanvasKeyframeToggle() and startCanvasKeyframeDrag() perform this conversion themselves; use this function when you construct a CanvasKeyframeChange yourself, for example to write a value edited in an inspector as a keyframe at the playhead.

Parameters​

An object with the following properties:

track​

The TimelineTrackData of the sequence from controller.timeline. Only keyframeDisplayOffset and keyframePlaybackRate are read.

propStatus​

How the prop is written in the source, as the props of getNodeProps() report it, or null. A keyframed status resolves rounding errors of the conversion to the existing keyframe frame, so an edit at a displayed keyframe hits that keyframe.

frame​

The composition frame to convert.

Return value​

The frame in the clock of the interpolation. Pass it as frame of an add or remove operation to updateNodeKeyframes().

Compatibility​

BrowsersEnvironments
Chrome
Firefox
Safari

See also​