mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-11-09 23:43:35 +00:00
fix(hud-overlay): ignore duplicate drag mousemove events to stop hold-drift
This commit is contained in:
1 parent
84958ee04b
commit
2d34ecc3c1
2 files changed
+15
No files matched your search
@@ -183,6 +183,7 @@ ipcMain.on("hud-overlay-set-ignore-mouse", (_event, ignore: boolean) => {
|
||||
});
|
||||
|
||||
let hudDragOffset: { x: number; y: number } | null = null;
|
||||
let hudDragLastCursor: { x: number; y: number } | null = null;
|
||||
|
||||
ipcMain.on("hud-overlay-drag", (_event, phase: string, screenX: number, screenY: number) => {
|
||||
if (!hudOverlayWindow || hudOverlayWindow.isDestroyed()) return;
|
||||
@@ -190,13 +191,20 @@ ipcMain.on("hud-overlay-drag", (_event, phase: string, screenX: number, screenY:
|
||||
if (phase === "start") {
|
||||
const bounds = hudOverlayWindow.getBounds();
|
||||
hudDragOffset = { x: screenX - bounds.x, y: screenY - bounds.y };
|
||||
hudDragLastCursor = { x: screenX, y: screenY };
|
||||
} else if (phase === "move" && hudDragOffset) {
|
||||
if (hudDragLastCursor && hudDragLastCursor.x === screenX && hudDragLastCursor.y === screenY) {
|
||||
return;
|
||||
}
|
||||
|
||||
hudDragLastCursor = { x: screenX, y: screenY };
|
||||
hudOverlayWindow.setPosition(
|
||||
Math.round(screenX - hudDragOffset.x),
|
||||
Math.round(screenY - hudDragOffset.y),
|
||||
);
|
||||
} else if (phase === "end") {
|
||||
hudDragOffset = null;
|
||||
hudDragLastCursor = null;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user