summaryrefslogtreecommitdiff
path: root/apps/web/src/hooks/use-timeline-element-resize.ts
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2025-07-26 13:13:27 +0200
committerMaze Winther <mazewinther@gmail.com>2025-07-26 13:13:27 +0200
commit14475dc9a692aeffa8ef3caccecc1d3164ce4cfc (patch)
treec3688bc5b2eeef45a5ce67bca4be8a636b987ec2 /apps/web/src/hooks/use-timeline-element-resize.ts
parentf149ab3b6cad8ba3af370d86f9f2bcd4d77b1870 (diff)
downloadopencut-14475dc9a692aeffa8ef3caccecc1d3164ce4cfc.tar.gz
fix: prevent resizing elements on the timeline further than the timeline start
Diffstat (limited to 'apps/web/src/hooks/use-timeline-element-resize.ts')
-rw-r--r--apps/web/src/hooks/use-timeline-element-resize.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/apps/web/src/hooks/use-timeline-element-resize.ts b/apps/web/src/hooks/use-timeline-element-resize.ts
index 3afa637b..e7d46dff 100644
--- a/apps/web/src/hooks/use-timeline-element-resize.ts
+++ b/apps/web/src/hooks/use-timeline-element-resize.ts
@@ -133,8 +133,10 @@ export function useTimelineElementResize({
if (canExtendElementDuration()) {
// Text/Image: extend element to the left by moving startTime and increasing duration
const extensionAmount = Math.abs(calculated);
- const newStartTime = element.startTime - extensionAmount;
- const newDuration = element.duration + extensionAmount;
+ const maxExtension = element.startTime;
+ const actualExtension = Math.min(extensionAmount, maxExtension);
+ const newStartTime = element.startTime - actualExtension;
+ const newDuration = element.duration + actualExtension;
// Keep trimStart at 0 and extend the element
updateElementTrim(