diff options
| author | Maze <mazewinther@gmail.com> | 2026-04-05 13:15:58 +0200 |
|---|---|---|
| committer | Maze <mazewinther@gmail.com> | 2026-04-05 13:15:58 +0200 |
| commit | 1bd9fac203f09736c1225bbbe19e5d7cc31c0b93 (patch) | |
| tree | d5c65add056209043e627a53e47e6ebbf74e64c6 /apps/web/src/lib/commands/timeline/element/keyframes/remove-keyframe.ts | |
| parent | 69da5bee0c50f331ec59a510d0cf0d45779bab31 (diff) | |
| download | opencut-1bd9fac203f09736c1225bbbe19e5d7cc31c0b93.tar.gz | |
refactor: rewrite animation system to use bindings and scalar channels
Diffstat (limited to 'apps/web/src/lib/commands/timeline/element/keyframes/remove-keyframe.ts')
| -rw-r--r-- | apps/web/src/lib/commands/timeline/element/keyframes/remove-keyframe.ts | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/apps/web/src/lib/commands/timeline/element/keyframes/remove-keyframe.ts b/apps/web/src/lib/commands/timeline/element/keyframes/remove-keyframe.ts index b5c7550d..71b2ac21 100644 --- a/apps/web/src/lib/commands/timeline/element/keyframes/remove-keyframe.ts +++ b/apps/web/src/lib/commands/timeline/element/keyframes/remove-keyframe.ts @@ -1,8 +1,9 @@ import { EditorCore } from "@/core"; import { - getChannel, - getChannelValueAtTime, + hasKeyframesForPath, + getKeyframeById, removeElementKeyframe, + resolveAnimationPathValueAtTime, resolveAnimationTarget, } from "@/lib/animation"; import { Command, type CommandResult } from "@/lib/commands/base-command"; @@ -19,17 +20,6 @@ function sampleValueBeforeRemoval({ propertyPath: AnimationPath; keyframeId: string; }): AnimationValue | null { - const channel = getChannel({ - animations: element.animations, - propertyPath, - }); - const keyframe = channel?.keyframes.find( - (candidate) => candidate.id === keyframeId, - ); - if (!channel || !keyframe) { - return null; - } - const target = resolveAnimationTarget({ element, path: propertyPath }); if (!target) { return null; @@ -39,9 +29,19 @@ function sampleValueBeforeRemoval({ return null; } - return getChannelValueAtTime({ - channel, - time: keyframe.time, + const keyframe = getKeyframeById({ + animations: element.animations, + propertyPath, + keyframeId, + }); + if (!keyframe) { + return null; + } + + return resolveAnimationPathValueAtTime({ + animations: element.animations, + propertyPath, + localTime: keyframe.time, fallbackValue: baseValue, }); } @@ -72,8 +72,10 @@ function removeKeyframeAndPersist({ keyframeId, }); - const isChannelNowEmpty = - getChannel({ animations: nextAnimations, propertyPath }) === undefined; + const isChannelNowEmpty = !hasKeyframesForPath({ + animations: nextAnimations, + propertyPath, + }); const shouldPersistToBase = isChannelNowEmpty && valueBefore !== null; const baseElement = shouldPersistToBase |
