summaryrefslogtreecommitdiff
path: root/apps/web/src/lib/commands/timeline/element/update-element-duration.ts
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2026-04-06 00:02:23 +0200
committerMaze Winther <mazewinther@gmail.com>2026-04-06 00:02:23 +0200
commit44d8c4c8764d49a8e8d0ae713432c07f07cb7597 (patch)
tree4657187279adb475ea710231feb3d0bd4add36ed /apps/web/src/lib/commands/timeline/element/update-element-duration.ts
parent20235d0724a70e6787b6cbdbfa054b1c5d8f62e9 (diff)
downloadopencut-44d8c4c8764d49a8e8d0ae713432c07f07cb7597.tar.gz
refactor: unify element updates into pipeline and centralize ripple
Diffstat (limited to 'apps/web/src/lib/commands/timeline/element/update-element-duration.ts')
-rw-r--r--apps/web/src/lib/commands/timeline/element/update-element-duration.ts58
1 files changed, 0 insertions, 58 deletions
diff --git a/apps/web/src/lib/commands/timeline/element/update-element-duration.ts b/apps/web/src/lib/commands/timeline/element/update-element-duration.ts
deleted file mode 100644
index 7ad62000..00000000
--- a/apps/web/src/lib/commands/timeline/element/update-element-duration.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import { Command, type CommandResult } from "@/lib/commands/base-command";
-import type { TimelineTrack } from "@/lib/timeline";
-import { EditorCore } from "@/core";
-import { clampAnimationsToDuration } from "@/lib/animation";
-
-export class UpdateElementDurationCommand extends Command {
- private savedState: TimelineTrack[] | null = null;
- private readonly trackId: string;
- private readonly elementId: string;
- private readonly duration: number;
-
- constructor({
- trackId,
- elementId,
- duration,
- }: {
- trackId: string;
- elementId: string;
- duration: number;
- }) {
- super();
- this.trackId = trackId;
- this.elementId = elementId;
- this.duration = duration;
- }
-
- execute(): CommandResult | undefined {
- const editor = EditorCore.getInstance();
- this.savedState = editor.timeline.getTracks();
-
- const updatedTracks = this.savedState.map((track) => {
- if (track.id !== this.trackId) return track;
- const newElements = track.elements.map((element) =>
- element.id === this.elementId
- ? {
- ...element,
- duration: this.duration,
- animations: clampAnimationsToDuration({
- animations: element.animations,
- duration: this.duration,
- }),
- }
- : element,
- );
- return { ...track, elements: newElements } as typeof track;
- });
-
- editor.timeline.updateTracks(updatedTracks);
- return undefined;
- }
-
- undo(): void {
- if (this.savedState) {
- const editor = EditorCore.getInstance();
- editor.timeline.updateTracks(this.savedState);
- }
- }
-}