Skip to content

Create polished demo videos without editing skills. Mac/Windows/Linux

Revert "Merge pull request #465 from webadderallorg/fix/issue395-zoom-independent-cursor"

wiiiii1235e3d7b0ee22c
diff --git a/src/components/video-editor/VideoPlayback.tsx b/src/components/video-editor/VideoPlayback.tsx
index b53636e8..836af7d5 100644
--- a/src/components/video-editor/VideoPlayback.tsx
+++ b/src/components/video-editor/VideoPlayback.tsx
@@ -2182,7 +2182,6 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
baseMaskRef.current,
showCursorRef.current,
!isPlayingRef.current || isSeekingRef.current,
- animationStateRef.current.appliedScale || 1,
);
smoothedCursorForHooks = mapSmoothedCursorToCanvasNormalized(
diff --git a/src/components/video-editor/videoPlayback/cursorRenderer.test.ts b/src/components/video-editor/videoPlayback/cursorRenderer.test.ts
deleted file mode 100644
index 97fd3594..00000000
--- a/src/components/video-editor/videoPlayback/cursorRenderer.test.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { describe, expect, it } from "vitest";
-
-import { resolveCursorDrawHeight } from "./cursorRenderer";
-
-describe("resolveCursorDrawHeight", () => {
- const viewport = {
- x: 100,
- y: 50,
- width: 960,
- height: 540,
- };
-
- it("keeps cursor output size stable when the zoom parent scales up", () => {
- const baseHeight = resolveCursorDrawHeight(viewport, 70, 1);
- const zoomedLocalHeight = resolveCursorDrawHeight(viewport, 70, 2);
-
- expect(zoomedLocalHeight).toBeCloseTo(baseHeight / 2, 6);
- expect(zoomedLocalHeight * 2).toBeCloseTo(baseHeight, 6);
- });
-
- it("falls back to unscaled sizing for invalid parent scale values", () => {
- const baseHeight = resolveCursorDrawHeight(viewport, 70, 1);
-
- expect(resolveCursorDrawHeight(viewport, 70, 0)).toBe(baseHeight);
- expect(resolveCursorDrawHeight(viewport, 70, Number.NaN)).toBe(baseHeight);
- });
-});
diff --git a/src/components/video-editor/videoPlayback/cursorRenderer.ts b/src/components/video-editor/videoPlayback/cursorRenderer.ts
index 1a06d003..644cf899 100644
--- a/src/components/video-editor/videoPlayback/cursorRenderer.ts
+++ b/src/components/video-editor/videoPlayback/cursorRenderer.ts
@@ -745,15 +745,6 @@ function getCursorViewportScale(viewport: CursorViewportRect) {
return Math.max(MIN_CURSOR_VIEWPORT_SCALE, viewport.width / REFERENCE_WIDTH);
}
-export function resolveCursorDrawHeight(
- viewport: CursorViewportRect,
- dotRadius: number,
- parentScale = 1,
-) {
- const safeParentScale = Number.isFinite(parentScale) && parentScale > 0 ? parentScale : 1;
- return (dotRadius * getCursorViewportScale(viewport)) / safeParentScale;
-}
-
function getCursorSwaySpringConfig(
smoothingFactor: number,
springTuning: CursorSpringTuning,
@@ -1070,7 +1061,6 @@ export class PixiCursorOverlay {
viewport: CursorViewportRect,
visible: boolean,
freeze = false,
- parentScale = 1,
): void {
if (!visible || samples.length === 0 || viewport.width <= 0 || viewport.height <= 0) {
this.container.visible = false;
@@ -1117,7 +1107,7 @@ export class PixiCursorOverlay {
const px = viewport.x + this.state.x * viewport.width;
const py = viewport.y + this.state.y * viewport.height;
- const h = resolveCursorDrawHeight(viewport, this.config.dotRadius, parentScale);
+ const h = this.config.dotRadius * getCursorViewportScale(viewport);
const { cursorType, clickBounceProgress } = getCursorVisualState(
samples,
timeMs,
@@ -1313,7 +1303,6 @@ export function drawCursorOnCanvas(
viewport: CursorViewportRect,
smoothedState: SmoothedCursorState,
config: CursorRenderConfig = DEFAULT_CURSOR_CONFIG,
- parentScale = 1,
): void {
if (samples.length === 0 || viewport.width <= 0 || viewport.height <= 0) return;
@@ -1327,7 +1316,7 @@ export function drawCursorOnCanvas(
const px = viewport.x + smoothedState.x * viewport.width;
const py = viewport.y + smoothedState.y * viewport.height;
- const h = resolveCursorDrawHeight(viewport, config.dotRadius, parentScale);
+ const h = config.dotRadius * getCursorViewportScale(viewport);
const { cursorType, clickBounceProgress } = getCursorVisualState(
samples,
timeMs,
diff --git a/src/lib/exporter/frameRenderer.ts b/src/lib/exporter/frameRenderer.ts
index f390414e..3a01403e 100644
--- a/src/lib/exporter/frameRenderer.ts
+++ b/src/lib/exporter/frameRenderer.ts
@@ -1626,12 +1626,6 @@ export class FrameRenderer {
const timeMs = this.currentVideoTime * 1000;
const cursorTimeMs = cursorTimestamp / 1000;
- const TICKS_PER_FRAME = 1;
-
- for (let i = 0; i < TICKS_PER_FRAME; i++) {
- this.updateAnimationState(timeMs);
- }
-
if (this.cursorOverlay) {
this.cursorOverlay.update(
this.config.cursorTelemetry ?? [],
@@ -1639,7 +1633,6 @@ export class FrameRenderer {
layoutCache.maskRect,
this.config.showCursor ?? true,
false,
- this.animationState.appliedScale || 1,
);
}
@@ -1662,6 +1655,12 @@ export class FrameRenderer {
: null,
);
+ const TICKS_PER_FRAME = 1;
+
+ for (let i = 0; i < TICKS_PER_FRAME; i++) {
+ this.updateAnimationState(timeMs);
+ }
+
applyZoomTransform({
cameraContainer: this.cameraContainer,
zoomBlurFilter: this.zoomBlurFilter,
@@ -2111,8 +2110,6 @@ export class FrameRenderer {
const timeMs = this.currentVideoTime * 1000;
const cursorTimeMs = cursorTimestamp / 1000;
- this.updateAnimationState(timeMs);
-
if (this.cursorOverlay) {
this.cursorOverlay.update(
this.config.cursorTelemetry ?? [],
@@ -2120,7 +2117,6 @@ export class FrameRenderer {
layoutCache.maskRect,
this.config.showCursor ?? true,
false,
- this.animationState.appliedScale || 1,
);
}
@@ -2133,6 +2129,8 @@ export class FrameRenderer {
},
);
+ this.updateAnimationState(timeMs);
+
applyZoomTransform({
cameraContainer: this.cameraContainer,
zoomBlurFilter: this.zoomBlurFilter,
diff --git a/src/lib/exporter/modernFrameRenderer.ts b/src/lib/exporter/modernFrameRenderer.ts
index 20517938..cf52faea 100644
--- a/src/lib/exporter/modernFrameRenderer.ts
+++ b/src/lib/exporter/modernFrameRenderer.ts
@@ -2885,8 +2885,6 @@ export class FrameRenderer {
const timeMs = this.currentVideoTime * 1000;
const cursorTimeMs = cursorTimestamp / 1000;
- this.updateAnimationState(timeMs);
-
if (this.cursorOverlay) {
this.cursorOverlay.update(
this.config.cursorTelemetry ?? [],
@@ -2894,10 +2892,11 @@ export class FrameRenderer {
layoutCache.maskRect,
this.config.showCursor ?? true,
false,
- this.animationState.appliedScale || 1,
);
}
+ this.updateAnimationState(timeMs);
+
applyZoomTransform({
cameraContainer: this.cameraContainer,
zoomBlurFilter: this.zoomBlurFilter,
@@ -3133,8 +3132,6 @@ export class FrameRenderer {
const timeMs = this.currentVideoTime * 1000;
const cursorTimeMs = cursorTimestamp / 1000;
- this.updateAnimationState(timeMs);
-
if (this.cursorOverlay) {
this.cursorOverlay.update(
this.config.cursorTelemetry ?? [],
@@ -3142,10 +3139,11 @@ export class FrameRenderer {
layoutCache.maskRect,
this.config.showCursor ?? true,
false,
- this.animationState.appliedScale || 1,
);
}
+ this.updateAnimationState(timeMs);
+
applyZoomTransform({
cameraContainer: this.cameraContainer,
zoomBlurFilter: this.zoomBlurFilter,