UNPKG

1.09 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.useCurrentFrame = exports.useAbsoluteCurrentFrame = void 0;
4const react_1 = require("react");
5const sequencing_1 = require("./sequencing");
6const timeline_position_state_1 = require("./timeline-position-state");
7const useAbsoluteCurrentFrame = () => {
8 const timelinePosition = (0, timeline_position_state_1.useTimelinePosition)();
9 return timelinePosition;
10};
11exports.useAbsoluteCurrentFrame = useAbsoluteCurrentFrame;
12/**
13 * Get the current frame of the video.
14 * Frames are 0-indexed, meaning the first frame is 0, the last frame is the duration of the composition in frames minus one.
15 * @link https://www.remotion.dev/docs/use-current-frame
16 */
17const useCurrentFrame = () => {
18 const frame = (0, exports.useAbsoluteCurrentFrame)();
19 const context = (0, react_1.useContext)(sequencing_1.SequenceContext);
20 const contextOffset = context
21 ? context.cumulatedFrom + context.relativeFrom
22 : 0;
23 return frame - contextOffset;
24};
25exports.useCurrentFrame = useCurrentFrame;