Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

refactor(cursor): use DEFAULT_CROP_REGION constant, drop redundant default

Etienne Lescotc2ba750460f1
diff --git a/src/components/video-editor/VideoPlayback.tsx b/src/components/video-editor/VideoPlayback.tsx
index 5f44acb30..6550b378b 100644
--- a/src/components/video-editor/VideoPlayback.tsx
+++ b/src/components/video-editor/VideoPlayback.tsx
@@ -58,6 +58,7 @@ import {
type BlurData,
type CursorTelemetryPoint,
computeRotation3DContainScale,
+ DEFAULT_CROP_REGION,
DEFAULT_ROTATION_3D,
getZoomScale,
isRotation3DIdentity,
@@ -1562,7 +1563,7 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
baseMaskRef.current,
showCursorRef.current && !hasNativeCursorRecordingRef.current,
!isPlayingRef.current || isSeekingRef.current,
- cropRegionRef.current ?? { x: 0, y: 0, width: 1, height: 1 },
+ cropRegionRef.current,
);
}
@@ -1601,7 +1602,7 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
: frame.sample;
const cameraContainer = cameraContainerRef.current;
const videoContainer = videoContainerRef.current;
- const cropRegionValue = cropRegionRef.current ?? { x: 0, y: 0, width: 1, height: 1 };
+ const cropRegionValue = cropRegionRef.current ?? DEFAULT_CROP_REGION;
const projectedLocalPoint = projectNativeCursorToLocal({
cropRegion: cropRegionValue,
maskRect: baseMaskRef.current,
@@ -1638,7 +1639,7 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
getNativeCursorClickBounceScale(cursorClickBounceRef.current, bounceProgress);
// Normalize cursor size to the displayed video width so the cursor
// appears at the same fraction of the video in both preview and export.
- const crop = cropRegionRef.current ?? { x: 0, y: 0, width: 1, height: 1 };
+ const crop = cropRegionRef.current ?? DEFAULT_CROP_REGION;
const croppedVideoWidth = (videoRef.current?.videoWidth ?? 0) * crop.width;
const sizeNorm =
croppedVideoWidth > 0 ? baseMaskRef.current.width / croppedVideoWidth : 1;
diff --git a/src/components/video-editor/videoPlayback/cursorRenderer.ts b/src/components/video-editor/videoPlayback/cursorRenderer.ts
index aa11456c1..4b2ba3a8a 100644
--- a/src/components/video-editor/videoPlayback/cursorRenderer.ts
+++ b/src/components/video-editor/videoPlayback/cursorRenderer.ts
@@ -1,6 +1,6 @@
import { Assets, BlurFilter, Container, Graphics, Sprite, Texture } from "pixi.js";
import { MotionBlurFilter } from "pixi-filters/motion-blur";
-import type { CropRegion, CursorTelemetryPoint } from "../types";
+import { type CropRegion, type CursorTelemetryPoint, DEFAULT_CROP_REGION } from "../types";
import {
createSpringState,
getCursorSpringConfig,
@@ -627,7 +627,7 @@ export class PixiCursorOverlay {
return;
}
- const crop = cropRegion ?? { x: 0, y: 0, width: 1, height: 1 };
+ const crop = cropRegion ?? DEFAULT_CROP_REGION;
const target = interpolateCursorPosition(samples, timeMs);
if (!target) {