fix: prevent resizing elements on the timeline further than the timeline start
This commit is contained in:
parent
f149ab3b6c
commit
14475dc9a6
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -754,13 +754,16 @@ export const useTimelineStore = create<TimelineStore>((set, get) => {
|
|||
pushHistory = true
|
||||
) => {
|
||||
if (pushHistory) get().pushHistory();
|
||||
const clampedStartTime = Math.max(0, startTime);
|
||||
updateTracksAndSave(
|
||||
get()._tracks.map((track) =>
|
||||
track.id === trackId
|
||||
? {
|
||||
...track,
|
||||
elements: track.elements.map((element) =>
|
||||
element.id === elementId ? { ...element, startTime } : element
|
||||
element.id === elementId
|
||||
? { ...element, startTime: clampedStartTime }
|
||||
: element
|
||||
),
|
||||
}
|
||||
: track
|
||||
|
|
@ -799,8 +802,7 @@ export const useTimelineStore = create<TimelineStore>((set, get) => {
|
|||
|
||||
const updatedElements = currentTrack.elements.map((currentElement) => {
|
||||
if (currentElement.id === elementId && currentTrack.id === trackId) {
|
||||
// Update the moved element
|
||||
return { ...currentElement, startTime: newStartTime };
|
||||
return { ...currentElement, startTime: Math.max(0, newStartTime) };
|
||||
}
|
||||
|
||||
// Only apply ripple effects if we should process this track
|
||||
|
|
|
|||
Loading…
Reference in New Issue