Skip to content

The open-source full-stack studio for Opus 5.5 motion video. Reverse engineering for any video. Code video with HTML: recreate, edit and render. BYOA + BYOK · Motion.md · Images, Video, Music & Voice.

1.1 KB
Raw Blame
import { isMultiDragActive, multiDragDeltaSeconds } from "./timelineMultiDragPreview";
import type { MultiDragPreviewInput } from "./timelineMultiDragPreview";
import type { TimelineTimeRange } from "../lib/timelineClipIndex";

/** The extra render window a live multi-drag needs: its passengers still draw
 *  at their ORIGIN position, offset by the drag delta, outside the normal
 *  virtualized range. Empty when nothing is dragging. */
export function useTimelineMultiDragActorWindows(
  multiDragPreview: MultiDragPreviewInput | null,
  rowsVirtualized: boolean,
  renderTimeRange: TimelineTimeRange,
) {
  const multiDragDelta =
    multiDragPreview && isMultiDragActive(multiDragPreview)
      ? multiDragDeltaSeconds(multiDragPreview)
      : 0;
  const actorWindows =
    rowsVirtualized && multiDragPreview && multiDragDelta !== 0
      ? [
          {
            range: {
              start: renderTimeRange.start - multiDragDelta,
              end: renderTimeRange.end - multiDragDelta,
            },
            identities: multiDragPreview.selectedKeys,
          },
        ]
      : [];
  return actorWindows;
}