UNPKG

1.52 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.Freeze = void 0;
4const jsx_runtime_1 = require("react/jsx-runtime");
5const react_1 = require("react");
6const sequencing_1 = require("./sequencing");
7const timeline_position_state_1 = require("./timeline-position-state");
8const Freeze = ({ frame, children }) => {
9 if (typeof frame === 'undefined') {
10 throw new Error(`The <Freeze /> component requires a 'frame' prop, but none was passed.`);
11 }
12 if (typeof frame !== 'number') {
13 throw new Error(`The 'frame' prop of <Freeze /> must be a number, but is of type ${typeof frame}`);
14 }
15 if (Number.isNaN(frame)) {
16 throw new Error(`The 'frame' prop of <Freeze /> must be a real number, but it is NaN.`);
17 }
18 if (!Number.isFinite(frame)) {
19 throw new Error(`The 'frame' prop of <Freeze /> must be a finite number, but it is ${frame}.`);
20 }
21 const context = (0, react_1.useContext)(timeline_position_state_1.TimelineContext);
22 const value = (0, react_1.useMemo)(() => {
23 return {
24 ...context,
25 playing: false,
26 imperativePlaying: {
27 current: false,
28 },
29 frame,
30 };
31 }, [context, frame]);
32 return ((0, jsx_runtime_1.jsx)(timeline_position_state_1.TimelineContext.Provider, { value: value, children: (0, jsx_runtime_1.jsx)(sequencing_1.SequenceContext.Provider, { value: null, children: children }, void 0) }, void 0));
33};
34exports.Freeze = Freeze;