Skip to content

🎥 Make videos programmatically with React

persist outframe without effects

Jonny Burger91f2df4df9fb
diff --git a/packages/cli/src/editor/components/TimelineInOutToggle.tsx b/packages/cli/src/editor/components/TimelineInOutToggle.tsx
index 24bcaf671c..96f1c2165c 100644
--- a/packages/cli/src/editor/components/TimelineInOutToggle.tsx
+++ b/packages/cli/src/editor/components/TimelineInOutToggle.tsx
@@ -49,8 +49,6 @@ export const TimelineInOutPointToggle: React.FC = () => {
const timelinePosition = Internals.Timeline.useTimelinePosition();
const {inFrame, outFrame} = useTimelineInOutFramePosition();
- console.log({inFrame, outFrame});
-
const {setInAndOutFrames} = useTimelineSetInOutFramePosition();
const isStill = useIsStill();
const videoConfig = Internals.useUnsafeVideoConfig();
@@ -281,35 +279,6 @@ export const TimelineInOutPointToggle: React.FC = () => {
};
}, [confId, keybindings, onInMark, onInOutClear, onOutMark]);
- // If duration changes and it goes out of range, we reset
- useEffect(() => {
- if (outFrame === null) {
- return;
- }
-
- if (!videoConfig) {
- return;
- }
-
- if (outFrame >= videoConfig.durationInFrames - 1) {
- onInOutClear(videoConfig.id);
- }
- }, [onInOutClear, outFrame, videoConfig]);
-
- useEffect(() => {
- if (inFrame === null) {
- return;
- }
-
- if (!videoConfig) {
- return;
- }
-
- if (inFrame >= videoConfig.durationInFrames - 1) {
- onInOutClear(videoConfig.id);
- }
- }, [onInOutClear, inFrame, videoConfig]);
-
useImperativeHandle(
inOutHandles,
() => {
diff --git a/packages/cli/src/editor/state/in-out.ts b/packages/cli/src/editor/state/in-out.ts
index 6d606de1bc..cc90f2fe26 100644
--- a/packages/cli/src/editor/state/in-out.ts
+++ b/packages/cli/src/editor/state/in-out.ts
@@ -33,7 +33,25 @@ export const useTimelineInOutFramePosition = (): InOutValue => {
return {inFrame: null, outFrame: null};
}
- return state[videoConfig.id] ?? {inFrame: null, outFrame: null};
+ const maxFrame = videoConfig.durationInFrames - 1;
+
+ const actualInFrame = state[videoConfig.id]?.inFrame ?? null;
+ const actualOutFrame = state[videoConfig.id]?.outFrame ?? null;
+
+ return {
+ inFrame:
+ actualInFrame === null
+ ? null
+ : actualInFrame >= maxFrame
+ ? null
+ : actualInFrame,
+ outFrame:
+ actualOutFrame === null
+ ? null
+ : actualOutFrame >= maxFrame
+ ? null
+ : actualOutFrame,
+ };
};
export const useTimelineSetInOutFramePosition =