Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

feat(desktop): let the recording card be dragged anywhere

Luis Ortiza31ee3d11189
diff --git a/apps/desktop/src/main/overlay/index.ts b/apps/desktop/src/main/overlay/index.ts
index dfa462c..1fcd817 100644
--- a/apps/desktop/src/main/overlay/index.ts
+++ b/apps/desktop/src/main/overlay/index.ts
@@ -130,6 +130,7 @@ export class CaptureOverlay {
private editors: BrowserWindow[] = [];
private boundary: BrowserWindow | null = null;
private controls: BrowserWindow | null = null;
+ private anchor: { right: number; bottom: number } | null = null;
private intro: BrowserWindow | null = null;
private introDone: ((finished: boolean) => void) | null = null;
private current: OverlayState = 'hidden';
@@ -265,11 +266,15 @@ export class CaptureOverlay {
private positionControls(): void {
if (!this.controls || this.controls.isDestroyed()) return;
- const { workArea } = screen.getDisplayMatching(this.rect);
const { width, height } = this.size;
+ const { workArea } = this.anchor
+ ? screen.getDisplayNearestPoint({ x: this.anchor.right - 1, y: this.anchor.bottom - 1 })
+ : screen.getDisplayMatching(this.rect);
+ const right = this.anchor?.right ?? workArea.x + workArea.width - CONTROLS.margin;
+ const bottom = this.anchor?.bottom ?? workArea.y + workArea.height - CONTROLS.margin;
this.controls.setBounds({
- x: Math.round(Math.max(workArea.x + workArea.width - width - CONTROLS.margin, workArea.x)),
- y: Math.round(Math.max(workArea.y + workArea.height - height - CONTROLS.margin, workArea.y)),
+ x: Math.round(Math.max(Math.min(right - width, workArea.x + workArea.width - width), workArea.x)),
+ y: Math.round(Math.max(Math.min(bottom - height, workArea.y + workArea.height - height), workArea.y)),
width,
height,
});
@@ -298,6 +303,17 @@ export class CaptureOverlay {
if (!this.controls) {
this.controls = overlayWindow({ x: 0, y: 0, ...this.size }, 'controls', true, false);
this.controls.setIgnoreMouseEvents(false);
+ this.controls.setMovable(true);
+ const card = this.controls;
+ let dragged = false;
+ card.on('will-move', () => {
+ dragged = true;
+ });
+ card.on('move', () => {
+ if (!dragged) return;
+ const moved = card.getBounds();
+ this.anchor = { right: moved.x + moved.width, bottom: moved.y + moved.height };
+ });
}
this.positionControls();
}