mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-25 15:25:44 +00:00
fix(launch): keep HUD interactive after short drags
This commit is contained in:
@@ -1,27 +1,27 @@
|
||||
import {
|
||||
AppWindow,
|
||||
ArrowCircleUp as ArrowUpCircle,
|
||||
ArrowClockwise as RefreshCw,
|
||||
CaretUp as ChevronUp,
|
||||
CheckCircle as CheckCircle2,
|
||||
DotsThreeVertical as MoreVertical,
|
||||
CaretUp as ChevronUp,
|
||||
Eye,
|
||||
EyeSlash as EyeOff,
|
||||
FolderOpen,
|
||||
Translate as Languages,
|
||||
Microphone as Mic,
|
||||
MicrophoneSlash as MicOff,
|
||||
Minus,
|
||||
Monitor,
|
||||
DotsThreeVertical as MoreVertical,
|
||||
Pause,
|
||||
Play,
|
||||
SpeakerHigh as Volume2,
|
||||
SpeakerX as VolumeX,
|
||||
ArrowClockwise as RefreshCw,
|
||||
Stop as Square,
|
||||
Timer,
|
||||
Translate as Languages,
|
||||
VideoCamera as Video,
|
||||
VideoCamera as VideoIcon,
|
||||
VideoCameraSlash as VideoOff,
|
||||
SpeakerHigh as Volume2,
|
||||
SpeakerX as VolumeX,
|
||||
X,
|
||||
} from "@phosphor-icons/react";
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
@@ -41,6 +41,7 @@ import { ContentClamp } from "../ui/content-clamp";
|
||||
import ProjectBrowserDialog, {
|
||||
type ProjectLibraryEntry,
|
||||
} from "../video-editor/ProjectBrowserDialog";
|
||||
import { shouldRestoreHudMousePassthroughAfterDrag } from "./hudMousePassthrough";
|
||||
import styles from "./LaunchWindow.module.css";
|
||||
|
||||
interface DesktopSource {
|
||||
@@ -465,7 +466,22 @@ export function LaunchWindow() {
|
||||
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
|
||||
event.currentTarget.releasePointerCapture(event.pointerId);
|
||||
}
|
||||
if (wasDragging) {
|
||||
const hudBounds = hudContentRef.current?.getBoundingClientRect();
|
||||
if (
|
||||
wasDragging &&
|
||||
shouldRestoreHudMousePassthroughAfterDrag(
|
||||
hudBounds
|
||||
? {
|
||||
left: hudBounds.left,
|
||||
top: hudBounds.top,
|
||||
right: hudBounds.right,
|
||||
bottom: hudBounds.bottom,
|
||||
}
|
||||
: null,
|
||||
event.clientX,
|
||||
event.clientY,
|
||||
)
|
||||
) {
|
||||
window.electronAPI?.hudOverlaySetIgnoreMouse?.(true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { shouldRestoreHudMousePassthroughAfterDrag } from "./hudMousePassthrough";
|
||||
|
||||
describe("shouldRestoreHudMousePassthroughAfterDrag", () => {
|
||||
it("keeps the HUD interactive when the pointer is still inside the HUD", () => {
|
||||
expect(
|
||||
shouldRestoreHudMousePassthroughAfterDrag(
|
||||
{ left: 100, top: 200, right: 300, bottom: 260 },
|
||||
180,
|
||||
230,
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps the HUD interactive when the pointer ends on the HUD edge", () => {
|
||||
expect(
|
||||
shouldRestoreHudMousePassthroughAfterDrag(
|
||||
{ left: 100, top: 200, right: 300, bottom: 260 },
|
||||
300,
|
||||
260,
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("restores passthrough when the pointer ends outside the HUD", () => {
|
||||
expect(
|
||||
shouldRestoreHudMousePassthroughAfterDrag(
|
||||
{ left: 100, top: 200, right: 300, bottom: 260 },
|
||||
301,
|
||||
261,
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("restores passthrough when no HUD bounds are available", () => {
|
||||
expect(shouldRestoreHudMousePassthroughAfterDrag(null, 180, 230)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
export interface HudInteractiveBounds {
|
||||
left: number;
|
||||
top: number;
|
||||
right: number;
|
||||
bottom: number;
|
||||
}
|
||||
|
||||
export function shouldRestoreHudMousePassthroughAfterDrag(
|
||||
bounds: HudInteractiveBounds | null,
|
||||
clientX: number,
|
||||
clientY: number,
|
||||
): boolean {
|
||||
if (!bounds) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (
|
||||
clientX < bounds.left ||
|
||||
clientX > bounds.right ||
|
||||
clientY < bounds.top ||
|
||||
clientY > bounds.bottom
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user