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

This reverts commit ea443f4e0e, reversing
changes made to ee4db6b3ad.
This commit is contained in:
wiiiii123
2026-05-09 10:09:37 +07:00
parent ea443f4e0e
commit 70b46ecb86
5 changed files with 14 additions and 57 deletions
@@ -2182,7 +2182,6 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
baseMaskRef.current,
showCursorRef.current,
!isPlayingRef.current || isSeekingRef.current,
animationStateRef.current.appliedScale || 1,
);
smoothedCursorForHooks = mapSmoothedCursorToCanvasNormalized(
@@ -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);
});
});
@@ -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,
+8 -10
View File
@@ -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,
+4 -6
View File
@@ -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,