diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-03-02 16:36:10 +0100 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-03-02 16:36:10 +0100 |
| commit | a526066b61f18b082adf6faeaf3e19f3d13cd77d (patch) | |
| tree | d4a67b7f6177080eae32787967d7a3c166c703b9 /apps/web/src/components/editor/panels/properties/hooks/use-element-playhead.ts | |
| parent | b0165da764971b8e7f37c9657d0aa81f9bc2dcc9 (diff) | |
| download | opencut-a526066b61f18b082adf6faeaf3e19f3d13cd77d.tar.gz | |
feat: wire ui to have keyframes for: opacity, text color, and all background properties
Diffstat (limited to 'apps/web/src/components/editor/panels/properties/hooks/use-element-playhead.ts')
| -rw-r--r-- | apps/web/src/components/editor/panels/properties/hooks/use-element-playhead.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/apps/web/src/components/editor/panels/properties/hooks/use-element-playhead.ts b/apps/web/src/components/editor/panels/properties/hooks/use-element-playhead.ts new file mode 100644 index 00000000..46e6cb6d --- /dev/null +++ b/apps/web/src/components/editor/panels/properties/hooks/use-element-playhead.ts @@ -0,0 +1,24 @@ +import { useEditor } from "@/hooks/use-editor"; +import { getElementLocalTime } from "@/lib/animation"; +import { TIME_EPSILON_SECONDS } from "@/constants/animation-constants"; + +export function useElementPlayhead({ + startTime, + duration, +}: { + startTime: number; + duration: number; +}) { + const editor = useEditor(); + const playheadTime = editor.playback.getCurrentTime(); + const localTime = getElementLocalTime({ + timelineTime: playheadTime, + elementStartTime: startTime, + elementDuration: duration, + }); + const isPlayheadWithinElementRange = + playheadTime >= startTime - TIME_EPSILON_SECONDS && + playheadTime <= startTime + duration + TIME_EPSILON_SECONDS; + + return { localTime, isPlayheadWithinElementRange }; +} |
