Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Reuse canvas outlines during zoom

Jonny Burger9c24d865e515
diff --git a/packages/sdk/src/canvas-outline-overlay.tsx b/packages/sdk/src/canvas-outline-overlay.tsx
index 1ea92dc425..1f14d874d4 100644
--- a/packages/sdk/src/canvas-outline-overlay.tsx
+++ b/packages/sdk/src/canvas-outline-overlay.tsx
@@ -506,6 +506,8 @@ const ActiveCanvasOutlines = React.memo(
const {outlinesForRendering, outlinesByKey, targetsByKey} =
useCanvasOutlines({
containerRef,
+ contentRoot: null,
+ scale: null,
targets,
sequences,
hoverController: controller.hover,
diff --git a/packages/sdk/src/outline-geometry.ts b/packages/sdk/src/outline-geometry.ts
index eaf2d98b11..6d6f50d998 100644
--- a/packages/sdk/src/outline-geometry.ts
+++ b/packages/sdk/src/outline-geometry.ts
@@ -49,6 +49,57 @@ export type CanvasOutlinePath = {
readonly matrix: CanvasOutlineMatrix;
};
+/** Converts outline coordinates without changing the element's local dimensions. */
+export const scaleCanvasOutline = (
+ outline: CanvasOutline,
+ scale: number,
+): CanvasOutline => {
+ if (scale === 1) {
+ return outline;
+ }
+
+ const scalePoint = (point: CanvasOutlinePoint): CanvasOutlinePoint => ({
+ x: point.x * scale,
+ y: point.y * scale,
+ });
+ const scalePoints = ([
+ tl,
+ tr,
+ br,
+ bl,
+ ]: CanvasOutline['points']): CanvasOutline['points'] => [
+ scalePoint(tl),
+ scalePoint(tr),
+ scalePoint(br),
+ scalePoint(bl),
+ ];
+ const points = scalePoints(outline.points);
+ return {
+ ...outline,
+ points,
+ uncroppedPoints:
+ outline.uncroppedPoints === null
+ ? null
+ : outline.uncroppedPoints === outline.points
+ ? points
+ : scalePoints(outline.uncroppedPoints),
+ path:
+ outline.path === null
+ ? null
+ : {
+ d: outline.path.d,
+ matrix: {
+ a: outline.path.matrix.a * scale,
+ b: outline.path.matrix.b * scale,
+ c: outline.path.matrix.c * scale,
+ d: outline.path.matrix.d * scale,
+ e: outline.path.matrix.e * scale,
+ f: outline.path.matrix.f * scale,
+ },
+ },
+ };
+};
+
const mix = (from: number, to: number, progress: number): number => {
return from + (to - from) * progress;
};
diff --git a/packages/sdk/src/outline-measurement.ts b/packages/sdk/src/outline-measurement.ts
index ea179c56b4..fee094fff3 100644
--- a/packages/sdk/src/outline-measurement.ts
+++ b/packages/sdk/src/outline-measurement.ts
@@ -67,23 +67,34 @@ export const getTransformedSvgViewportPoints = ({
const quadToPoints = (
quad: DOMQuad,
- containerRect: DOMRect,
+ containerRect: Pick<DOMRect, 'left' | 'top'>,
+ scale: number,
): CanvasOutline['points'] => {
- // `getBoxQuads`/the ponyfill returns the quad in viewport coordinates.
- // The overlay <svg> is unscaled (the canvas `scale()`/pan live on a sibling
- // container, not the svg), so 1 user unit == 1 px and we only need to move
- // the quad into the svg's local space by subtracting its viewport origin.
- // We deliberately do not pass `relativeTo` to the ponyfill: when the target
- // is not an ancestor of the element, the polyfill cannot resolve the
- // coordinate space and leaves the quad in viewport coordinates.
return [
- {x: quad.p1.x - containerRect.left, y: quad.p1.y - containerRect.top},
- {x: quad.p2.x - containerRect.left, y: quad.p2.y - containerRect.top},
- {x: quad.p3.x - containerRect.left, y: quad.p3.y - containerRect.top},
- {x: quad.p4.x - containerRect.left, y: quad.p4.y - containerRect.top},
+ {
+ x: (quad.p1.x - containerRect.left) * scale,
+ y: (quad.p1.y - containerRect.top) * scale,
+ },
+ {
+ x: (quad.p2.x - containerRect.left) * scale,
+ y: (quad.p2.y - containerRect.top) * scale,
+ },
+ {
+ x: (quad.p3.x - containerRect.left) * scale,
+ y: (quad.p3.y - containerRect.top) * scale,
+ },
+ {
+ x: (quad.p4.x - containerRect.left) * scale,
+ y: (quad.p4.y - containerRect.top) * scale,
+ },
];
};
+type OutlineCoordinateSpace = {
+ readonly root: Element;
+ readonly scale: number;
+};
+
const isSvgSvgElement = (element: Element): element is SVGSVGElement => {
const ownerSvgSvgElement = element.ownerDocument.defaultView?.SVGSVGElement;
return (
@@ -121,16 +132,16 @@ const getSvgSvgElementViewport = (element: SVGSVGElement): SvgViewport => {
* we compose two consistent transforms:
*
* 1. The polyfill's CSS-transform-aware walk from the root <svg> to the
- * document element (document coordinates, no viewport scroll — FIX 15).
+ * composition root, or to the document element for viewport measurements.
* 2. `element.getCTM()`, the pure SVG-internal transform from user units to
* the root <svg>'s viewport. Cross-browser consistent, no CSS involved.
*
- * Finally we mirror `toViewportRelativeDocumentElementQuad`: subtract window
- * scroll to land in viewport coordinates, then subtract the overlay origin
- * (like `quadToPoints` does for HTML quads).
+ * Composition coordinates are projected to the host scale. Viewport measurements
+ * subtract window scroll and the overlay origin, like HTML quads.
*/
const getSvgElementScreenMatrix = (
element: SVGGraphicsElement,
+ coordinateSpace: OutlineCoordinateSpace | null,
): (SvgScreenCtm & {readonly is2D: boolean}) | null => {
const ownerSvg = element.ownerSVGElement;
const {documentElement} = element.ownerDocument;
@@ -139,6 +150,10 @@ const getSvgElementScreenMatrix = (
return null;
}
+ const relativeSpace = coordinateSpace?.root.contains(ownerSvg)
+ ? coordinateSpace
+ : null;
+
let walk;
try {
// Walking the root <svg> (not the path) avoids the polyfill's
@@ -146,7 +161,7 @@ const getSvgElementScreenMatrix = (
// coordinates by the path's `getBBox()` origin.
walk = getResultingTransformationBetweenElementAndAllAncestors(
ownerSvg,
- documentElement,
+ relativeSpace?.root ?? documentElement,
[],
);
} catch {
@@ -160,16 +175,23 @@ const getSvgElementScreenMatrix = (
}
const matrix = walk.multiply(ctm);
- const scrollX = win.scrollX ?? documentElement.scrollLeft ?? 0;
- const scrollY = win.scrollY ?? documentElement.scrollTop ?? 0;
+ const scrollX =
+ relativeSpace === null
+ ? (win.scrollX ?? documentElement.scrollLeft ?? 0)
+ : 0;
+ const scrollY =
+ relativeSpace === null
+ ? (win.scrollY ?? documentElement.scrollTop ?? 0)
+ : 0;
+ const scale = relativeSpace?.scale ?? 1;
return {
- a: matrix.a,
- b: matrix.b,
- c: matrix.c,
- d: matrix.d,
- e: matrix.e - scrollX,
- f: matrix.f - scrollY,
+ a: matrix.a * scale,
+ b: matrix.b * scale,
+ c: matrix.c * scale,
+ d: matrix.d * scale,
+ e: matrix.e * scale - scrollX,
+ f: matrix.f * scale - scrollY,
is2D: matrix.is2D,
};
};
@@ -177,6 +199,7 @@ const getSvgElementScreenMatrix = (
const getSvgSvgElementOutlinePoints = (
element: SVGSVGElement,
containerRect: DOMRect,
+ coordinateSpace: OutlineCoordinateSpace | null,
): CanvasOutline['points'] | null => {
const viewport = getSvgSvgElementViewport(element);
if (viewport.width === 0 && viewport.height === 0) {
@@ -189,13 +212,17 @@ const getSvgSvgElementOutlinePoints = (
return null;
}
+ const relativeSpace = coordinateSpace?.root.contains(element)
+ ? coordinateSpace
+ : null;
+
let walk;
try {
// The walk on the root <svg> includes its own CSS transform, unlike
// `getScreenCTM()` in WebKit, which ignores ancestor CSS transforms.
walk = getResultingTransformationBetweenElementAndAllAncestors(
element,
- documentElement,
+ relativeSpace?.root ?? documentElement,
[],
);
} catch {
@@ -209,7 +236,7 @@ const getSvgSvgElementOutlinePoints = (
// Compose the viewBox→viewport transform manually: root-svg `getCTM()`
// semantics are unreliable across browsers, and this keeps the math
- // dependency-free. `walk` maps viewport px → document coordinates.
+ // dependency-free. `walk` maps viewport px into the chosen coordinate space.
const viewBox = element.viewBox.baseVal;
const hasViewBox = viewBox.width > 0 && viewBox.height > 0;
const viewportWidth = element.width.baseVal.value;
@@ -259,20 +286,27 @@ const getSvgSvgElementOutlinePoints = (
translateY -= viewBox.y * scaleY;
}
- const scrollX = win.scrollX ?? documentElement.scrollLeft ?? 0;
- const scrollY = win.scrollY ?? documentElement.scrollTop ?? 0;
+ const scrollX =
+ relativeSpace === null
+ ? (win.scrollX ?? documentElement.scrollLeft ?? 0)
+ : 0;
+ const scrollY =
+ relativeSpace === null
+ ? (win.scrollY ?? documentElement.scrollTop ?? 0)
+ : 0;
+ const scale = relativeSpace?.scale ?? 1;
return getTransformedSvgViewportPoints({
viewport,
ctm: {
- a: walk.a * scaleX,
- b: walk.b * scaleX,
- c: walk.c * scaleY,
- d: walk.d * scaleY,
- e: walk.a * translateX + walk.c * translateY + walk.e - scrollX,
- f: walk.b * translateX + walk.d * translateY + walk.f - scrollY,
+ a: walk.a * scaleX * scale,
+ b: walk.b * scaleX * scale,
+ c: walk.c * scaleY * scale,
+ d: walk.d * scaleY * scale,
+ e: (walk.a * translateX + walk.c * translateY + walk.e) * scale - scrollX,
+ f: (walk.b * translateX + walk.d * translateY + walk.f) * scale - scrollY,
},
- containerRect,
+ containerRect: relativeSpace === null ? containerRect : {left: 0, top: 0},
});
};
@@ -289,24 +323,27 @@ const isSvgPathElement = (element: Element): element is SVGPathElement => {
const getPathOutline = ({
element,
containerRect,
+ coordinateSpace,
}: {
readonly element: SVGPathElement;
readonly containerRect: DOMRect;
+ readonly coordinateSpace: OutlineCoordinateSpace | null;
}): CanvasOutlinePath | null => {
const d = element.getAttribute('d');
if (d === null || d === '') {
return null;
}
- const ctm = getSvgElementScreenMatrix(element);
+ const ctm = getSvgElementScreenMatrix(element, coordinateSpace);
if (ctm === null || !ctm.is2D) {
// In a 3D CSS context no single 2D matrix can place the path; the
// polygon outline from `getBoxQuads` still applies.
return null;
}
- // Shift the translation into the overlay svg's local space, like every
- // other point source.
+ const origin = coordinateSpace?.root.contains(element.ownerSVGElement)
+ ? {left: 0, top: 0}
+ : containerRect;
return {
d,
matrix: {
@@ -314,8 +351,8 @@ const getPathOutline = ({
b: ctm.b,
c: ctm.c,
d: ctm.d,
- e: ctm.e - containerRect.left,
- f: ctm.f - containerRect.top,
+ e: ctm.e - origin.left,
+ f: ctm.f - origin.top,
},
};
};
@@ -324,24 +361,38 @@ const getElementOutlinePoints = (
element: Element,
elementRect: DOMRect,
containerRect: DOMRect,
+ coordinateSpace: OutlineCoordinateSpace | null,
): CanvasOutline['points'] | null => {
if (elementRect.width === 0 && elementRect.height === 0) {
return null;
}
if (isSvgSvgElement(element)) {
- return getSvgSvgElementOutlinePoints(element, containerRect);
+ return getSvgSvgElementOutlinePoints(
+ element,
+ containerRect,
+ coordinateSpace,
+ );
}
- const quads = getBoxQuadsPonyfill(element, {
- box: 'border',
- });
+ // The composition root is a real ancestor. Measuring relative to it avoids
+ // rounding the host's fractional viewport offsets before normalization.
+ // The sibling overlay cannot be used as `relativeTo` by the ponyfill.
+ const relativeTo = coordinateSpace?.root.contains(element)
+ ? coordinateSpace.root
+ : null;
+ const quads = getBoxQuadsPonyfill(
+ element,
+ relativeTo === null ? {box: 'border'} : {box: 'border', relativeTo},
+ );
const quad = quads?.[0];
if (!quad) {
return rectToPoints(elementRect, containerRect);
}
- return quadToPoints(quad, containerRect);
+ return relativeTo === null
+ ? quadToPoints(quad, containerRect, 1)
+ : quadToPoints(quad, {left: 0, top: 0}, coordinateSpace?.scale ?? 1);
};
export const cropCanvasOutlinePoints = (
@@ -376,6 +427,7 @@ export const cropCanvasOutlinePoints = (
export const measureCanvasOutlineTargets = (
container: Element,
targets: readonly CanvasOutlineTarget[],
+ coordinateSpace: OutlineCoordinateSpace | null,
): CanvasOutline[] => {
// Reuse shared ancestor geometry within this synchronous batch only.
resetBoxQuadsCache();
@@ -469,6 +521,7 @@ export const measureCanvasOutlineTargets = (
element,
elementRect,
containerRect,
+ coordinateSpace,
);
if (uncroppedPoints === null) {
continue;
@@ -478,7 +531,7 @@ export const measureCanvasOutlineTargets = (
const ownerHTMLElement = element.ownerDocument.defaultView?.HTMLElement;
const path = isSvgPathElement(element)
- ? getPathOutline({element, containerRect})
+ ? getPathOutline({element, containerRect, coordinateSpace})
: null;
const measured = {
diff --git a/packages/sdk/src/use-canvas-outline-measurements.ts b/packages/sdk/src/use-canvas-outline-measurements.ts
index 7ee14c68af..4df5f537ef 100644
--- a/packages/sdk/src/use-canvas-outline-measurements.ts
+++ b/packages/sdk/src/use-canvas-outline-measurements.ts
@@ -1,7 +1,8 @@
import type {MutableRefObject, RefObject} from 'react';
-import {useCallback, useLayoutEffect, useRef, useState} from 'react';
+import {useCallback, useLayoutEffect, useMemo, useRef, useState} from 'react';
import {Internals} from 'remotion';
import type {CanvasOutline, CanvasOutlineTarget} from './outline-geometry';
+import {scaleCanvasOutline} from './outline-geometry';
import {
canvasOutlinesAreEqual,
measureCanvasOutlineTargets,
@@ -10,10 +11,16 @@ import {getCanvasOutlineNodes} from './outline-nodes';
export const useCanvasOutlineMeasurements = ({
containerRef,
+ contentRoot,
+ scale,
targets,
updateOutlinesRef,
}: {
readonly containerRef: RefObject<SVGSVGElement | null>;
+ /** Observe composition mutations separately from the host's zoom and pan. */
+ readonly contentRoot: Element | null;
+ /** Cache at scale 1 and project to this scale. Null keeps container coordinates. */
+ readonly scale: number | null;
readonly targets: readonly CanvasOutlineTarget[];
readonly updateOutlinesRef: MutableRefObject<() => void> | null;
}): readonly CanvasOutline[] => {
@@ -24,6 +31,14 @@ export const useCanvasOutlineMeasurements = ({
const latestUpdateRef = useRef<() => void>(() => undefined);
const resizeObserverRef = useRef<ResizeObserver | null>(null);
const observedElementsRef = useRef<ReadonlySet<Element>>(new Set());
+ const measuredNodesRef = useRef(
+ new Map<CanvasOutlineTarget['ref'], readonly (Element | Text)[] | null>(),
+ );
+ const scaleRef = useRef(scale);
+ const normalize = scale !== null;
+ useLayoutEffect(() => {
+ scaleRef.current = scale;
+ }, [scale]);
const updateOutlines = useCallback(() => {
const container = containerRef.current;
@@ -42,8 +57,9 @@ export const useCanvasOutlineMeasurements = ({
const resizeObserver = resizeObserverRef.current;
if (resizeObserver !== null) {
const nextObservedElements = new Set<Element>();
- if (containerRef.current !== null) {
- nextObservedElements.add(containerRef.current);
+ // Zoom changes the overlay's CSS size, but only transforms its contents.
+ if (!normalize) {
+ nextObservedElements.add(container);
}
for (const target of targets) {
@@ -71,14 +87,33 @@ export const useCanvasOutlineMeasurements = ({
observedElementsRef.current = nextObservedElements;
}
- const nextOutlines = measureCanvasOutlineTargets(container, targets);
+ const measurementScale = scaleRef.current;
+ const measuredOutlines = measureCanvasOutlineTargets(
+ container,
+ targets,
+ contentRoot === null || measurementScale === null
+ ? null
+ : {root: contentRoot, scale: measurementScale},
+ );
+ const nextOutlines =
+ measurementScale === null
+ ? measuredOutlines
+ : measuredOutlines.map((outline) =>
+ scaleCanvasOutline(outline, 1 / measurementScale),
+ );
+ measuredNodesRef.current = new Map(
+ targets.map((target) => [
+ target.ref,
+ Internals.SequenceOutlineInternals.getNodes(target.ref),
+ ]),
+ );
if (canvasOutlinesAreEqual(outlinesRef.current, nextOutlines)) {
return;
}
outlinesRef.current = nextOutlines;
setOutlines(nextOutlines);
- }, [containerRef, targets]);
+ }, [containerRef, contentRoot, normalize, targets]);
useLayoutEffect(() => {
latestUpdateRef.current = updateOutlines;
@@ -101,6 +136,19 @@ export const useCanvasOutlineMeasurements = ({
};
const ownerWindow = containerRef.current?.ownerDocument.defaultView;
+ const onCommit = () => {
+ if (
+ !normalize ||
+ targets.some(
+ (target) =>
+ measuredNodesRef.current.get(target.ref) !==
+ Internals.SequenceOutlineInternals.getNodes(target.ref),
+ )
+ ) {
+ scheduleUpdate();
+ }
+ };
+
const hasAutomaticTargets = targets.some(
(target) =>
Internals.SequenceOutlineInternals.getNodes(target.ref) !== null,
@@ -109,7 +157,7 @@ export const useCanvasOutlineMeasurements = ({
latestUpdateRef.current = scheduleUpdate;
ownerWindow?.addEventListener(
Internals.CommitOrderInternals.eventName,
- scheduleUpdate,
+ onCommit,
);
scheduleUpdate();
} else {
@@ -120,14 +168,14 @@ export const useCanvasOutlineMeasurements = ({
active = false;
ownerWindow?.removeEventListener(
Internals.CommitOrderInternals.eventName,
- scheduleUpdate,
+ onCommit,
);
latestUpdateRef.current = () => undefined;
if (updateOutlinesRef?.current === updateOutlines) {
updateOutlinesRef.current = () => undefined;
}
};
- }, [containerRef, targets, updateOutlines, updateOutlinesRef]);
+ }, [containerRef, normalize, targets, updateOutlines, updateOutlinesRef]);
useLayoutEffect(() => {
const ownerWindow = containerRef.current?.ownerDocument.defaultView;
@@ -160,5 +208,36 @@ export const useCanvasOutlineMeasurements = ({
};
}, [containerRef]);
- return outlines;
+ useLayoutEffect(() => {
+ const ownerWindow = contentRoot?.ownerDocument.defaultView;
+ if (
+ contentRoot === null ||
+ !ownerWindow ||
+ typeof ownerWindow.MutationObserver === 'undefined'
+ ) {
+ return;
+ }
+
+ // Includes descendant-only edits and transforms on composition ancestors,
+ // while the host's scaled container and the outline overlay stay outside.
+ const observer = new ownerWindow.MutationObserver(() =>
+ latestUpdateRef.current(),
+ );
+ observer.observe(contentRoot, {
+ attributes: true,
+ characterData: true,
+ childList: true,
+ subtree: true,
+ });
+ return () => observer.disconnect();
+ }, [contentRoot]);
+
+ // Controls keep using overlay pixels, while zoom only projects cached geometry.
+ return useMemo(
+ () =>
+ scale === null
+ ? outlines
+ : outlines.map((outline) => scaleCanvasOutline(outline, scale)),
+ [outlines, scale],
+ );
};
diff --git a/packages/sdk/src/use-canvas-outlines.ts b/packages/sdk/src/use-canvas-outlines.ts
index 5913045293..dda4f13667 100644
--- a/packages/sdk/src/use-canvas-outlines.ts
+++ b/packages/sdk/src/use-canvas-outlines.ts
@@ -24,6 +24,8 @@ export type CanvasOutlineRenderTarget = Omit<
/** Measure and order a host's outline targets without subscribing to playback. */
export const useCanvasOutlines = <Target extends CanvasOutlineRenderTarget>({
containerRef,
+ contentRoot,
+ scale,
targets,
sequences,
hoverController,
@@ -31,6 +33,8 @@ export const useCanvasOutlines = <Target extends CanvasOutlineRenderTarget>({
updateOutlinesRef,
}: {
readonly containerRef: RefObject<SVGSVGElement | null>;
+ readonly contentRoot: Element | null;
+ readonly scale: number | null;
readonly targets: readonly Target[];
readonly sequences: readonly CanvasOutlineSequenceParent[];
readonly hoverController: CanvasHoverController;
@@ -57,6 +61,8 @@ export const useCanvasOutlines = <Target extends CanvasOutlineRenderTarget>({
);
const outlines = useCanvasOutlineMeasurements({
containerRef,
+ contentRoot,
+ scale,
targets: measurementTargets,
updateOutlinesRef,
});
diff --git a/packages/studio/src/components/Preview.tsx b/packages/studio/src/components/Preview.tsx
index 39c7575e9c..d9d3d7112c 100644
--- a/packages/studio/src/components/Preview.tsx
+++ b/packages/studio/src/components/Preview.tsx
@@ -381,8 +381,6 @@ const CompWhenItHasDimensions: React.FC<{
compositionHeight={(contentDimensions as Dimensions).height}
compositionWidth={(contentDimensions as Dimensions).width}
scale={scale}
- translationX={previewSize.translation.x}
- translationY={previewSize.translation.y}
/>
</div>
);
diff --git a/packages/studio/src/components/SelectedOutlineOverlay.tsx b/packages/studio/src/components/SelectedOutlineOverlay.tsx
index 45ca39cd23..55a6e78949 100644
--- a/packages/studio/src/components/SelectedOutlineOverlay.tsx
+++ b/packages/studio/src/components/SelectedOutlineOverlay.tsx
@@ -683,8 +683,6 @@ type SelectedOutlineOverlayProps = {
readonly compositionHeight: number;
readonly compositionWidth: number;
readonly scale: number;
- readonly translationX: number;
- readonly translationY: number;
};
type ActiveSelectedOutlineOverlayProps = Omit<
@@ -734,11 +732,8 @@ const ActiveSelectedOutlineOverlayUnmemoized: React.FC<
selectedSequenceKeys,
sequenceKeysContainingSelection,
sequences,
- translationX,
- translationY,
}) => {
const timelinePosition = Internals.Timeline.useTimelinePosition();
- const updateOutlinesRef = useRef<() => void>(() => undefined);
const selectableOutlines = useMemo(() => {
return getSelectableOutlines(timelinePosition);
}, [getSelectableOutlines, timelinePosition]);
@@ -806,9 +801,6 @@ const ActiveSelectedOutlineOverlayUnmemoized: React.FC<
],
);
- useLayoutEffect(() => {
- updateOutlinesRef.current();
- }, [scale, translationX, translationY]);
return (
<SelectedOutlineRenderer
compositionHeight={compositionHeight}
@@ -822,7 +814,6 @@ const ActiveSelectedOutlineOverlayUnmemoized: React.FC<
onSelect={onSelect}
scale={scale}
sequences={sequences}
- updateOutlinesRef={updateOutlinesRef}
/>
);
};
@@ -833,14 +824,7 @@ const ActiveSelectedOutlineOverlay = React.memo(
const SelectedOutlineOverlayUnmemoized: React.FC<
SelectedOutlineOverlayProps
-> = ({
- canvasHovered,
- compositionHeight,
- compositionWidth,
- scale,
- translationX,
- translationY,
-}) => {
+> = ({canvasHovered, compositionHeight, compositionWidth, scale}) => {
const {selectedItems, selectItem} = useTimelineSelection();
const currentSelection = useCurrentTimelineSelectionStateAsRef();
const sequences = Internals.useSequenceManagerSequences();
@@ -1120,8 +1104,6 @@ const SelectedOutlineOverlayUnmemoized: React.FC<
selectedSequenceKeys={selectedSequenceKeys}
sequenceKeysContainingSelection={sequenceKeysContainingSelection}
sequences={sequences}
- translationX={translationX}
- translationY={translationY}
/>
) : null}
</>
diff --git a/packages/studio/src/components/SelectedOutlineRenderer.tsx b/packages/studio/src/components/SelectedOutlineRenderer.tsx
index 0048b59a6a..2f83b3d090 100644
--- a/packages/studio/src/components/SelectedOutlineRenderer.tsx
+++ b/packages/studio/src/components/SelectedOutlineRenderer.tsx
@@ -6,6 +6,7 @@ import React, {
useMemo,
useRef,
} from 'react';
+import {Internals} from 'remotion';
import {timelineSequenceNodePathToKey} from '../helpers/timeline-node-path-key';
import {TimelineSequenceHoverContext} from '../state/timeline-sequence-hover';
import {ContextMenuForTarget} from './ContextMenu';
@@ -63,7 +64,6 @@ const SelectedOutlineRendererUnmemoized: React.FC<{
readonly sequences: Parameters<
typeof orderOutlinesForRendering
>[0]['sequences'];
- readonly updateOutlinesRef: React.MutableRefObject<() => void>;
}> = ({
compositionHeight,
compositionWidth,
@@ -76,7 +76,6 @@ const SelectedOutlineRendererUnmemoized: React.FC<{
onSelect,
scale,
sequences,
- updateOutlinesRef,
}) => {
const overlayRef = useRef<SVGSVGElement>(null);
const contextMenuOpenHandlersRef = useRef(
@@ -122,11 +121,13 @@ const SelectedOutlineRendererUnmemoized: React.FC<{
hoveredNodePathKey,
} = useCanvasOutlines({
containerRef: overlayRef,
+ contentRoot: Internals.portalNode(),
+ scale,
targets: outlineTargets,
sequences,
hoverController,
freezeOrder: dragging,
- updateOutlinesRef,
+ updateOutlinesRef: null,
});
const {
outlinesForEditingHandles,
diff --git a/packages/studio/src/components/WebMcp.tsx b/packages/studio/src/components/WebMcp.tsx
index 9765df88c1..cbff84a963 100644
--- a/packages/studio/src/components/WebMcp.tsx
+++ b/packages/studio/src/components/WebMcp.tsx
@@ -1116,6 +1116,7 @@ export const WebMcp: FC = () => {
includeOutsideContainer: true,
};
}),
+ null,
);
const measurementsByKey = new Map(
measuredOutlines.map((outline) => [outline.key, outline]),