Skip to content

🎥 Make videos programmatically with React

cool

Jonny Burger81787b7d1813
diff --git a/packages/cli/src/editor/components/Timeline/TimelineDragHandler.tsx b/packages/cli/src/editor/components/Timeline/TimelineDragHandler.tsx
index 22e735b4b9..d8b5de304f 100644
--- a/packages/cli/src/editor/components/Timeline/TimelineDragHandler.tsx
+++ b/packages/cli/src/editor/components/Timeline/TimelineDragHandler.tsx
@@ -276,11 +276,14 @@ export const TimelineDragHandler: React.FC = () => {
'extend'
);
if (inOutDragging.dragging === 'in') {
+ if (frame < 1) {
+ return setInFrame(null);
+ }
+
const maxFrame = outFrame === null ? Infinity : outFrame - 1;
setInFrame(Math.min(maxFrame, frame));
} else {
- if (frame > videoConfig.durationInFrames - 1) {
- console.log('out out');
+ if (frame > videoConfig.durationInFrames - 2) {
return setOutFrame(null);
}
diff --git a/packages/cli/src/editor/components/TimelineInOutToggle.tsx b/packages/cli/src/editor/components/TimelineInOutToggle.tsx
index 6c83ef1e0b..85dda405e2 100644
--- a/packages/cli/src/editor/components/TimelineInOutToggle.tsx
+++ b/packages/cli/src/editor/components/TimelineInOutToggle.tsx
@@ -49,17 +49,19 @@ export const TimelineInOutPointToggle: React.FC = () => {
validOutFrame = videoConfig.durationInFrames - 1;
}
}
- } else {
- validOutFrame = timelinePosition;
- if (inFrame !== null && timelinePosition >= inFrame) {
- validInFrame =
- timelinePosition === inFrame
- ? timelinePosition - MIN_FRAMES_BETWEEN_POINTS
- : inFrame;
- if (validInFrame < 0) {
- validInFrame = 0;
- validOutFrame = timelinePosition + MIN_FRAMES_BETWEEN_POINTS;
- }
+
+ return {validInFrame, validOutFrame};
+ }
+
+ validOutFrame = timelinePosition;
+ if (inFrame !== null && timelinePosition >= inFrame) {
+ validInFrame =
+ timelinePosition === inFrame
+ ? timelinePosition - MIN_FRAMES_BETWEEN_POINTS
+ : inFrame;
+ if (validInFrame < 0) {
+ validInFrame = 0;
+ validOutFrame = timelinePosition + MIN_FRAMES_BETWEEN_POINTS;
}
}
@@ -74,7 +76,10 @@ export const TimelineInOutPointToggle: React.FC = () => {
}
const {validInFrame, validOutFrame} = getValidFrame('inFrame');
- setInFrame(inFrame ? null : validInFrame);
+
+ setInFrame((prev) => {
+ return prev ? null : validInFrame;
+ });
if (inFrame) {
setOutFrame(validOutFrame);
}
@@ -86,8 +91,8 @@ export const TimelineInOutPointToggle: React.FC = () => {
}
const {validOutFrame} = getValidFrame('outFrame');
- setOutFrame(outFrame ? null : validOutFrame);
- }, [getValidFrame, outFrame, setOutFrame, videoConfig]);
+ setOutFrame((prev) => (prev ? null : validOutFrame));
+ }, [getValidFrame, setOutFrame, videoConfig]);
useEffect(() => {
const iKey = keybindings.registerKeybinding('keypress', 'i', () => {