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 πŸ“–

fix(editor): let the text toolbar follow a shape while it is dragged

Luis Ortizc819045c9fd4
diff --git a/src/ui/shared/AnnotationEditor.tsx b/src/ui/shared/AnnotationEditor.tsx
index 6a92f9d..07f7b2f 100644
--- a/src/ui/shared/AnnotationEditor.tsx
+++ b/src/ui/shared/AnnotationEditor.tsx
@@ -514,21 +514,21 @@ export default function AnnotationEditor({ screenshot, tool, onDone, onCancel }:
}
const p = toImageSpace(e);
- if (drag.mode === 'move') {
+ if (drag.mode === 'move' || drag.mode === 'resize') {
const dx = p.x - drag.lastX;
const dy = p.y - drag.lastY;
drag.lastX = p.x;
drag.lastY = p.y;
- setAnnotations((prev) => prev.map((a) => (a.id === drag.id ? moveAnnotation(a, dx, dy) : a)));
- return;
- }
-
- if (drag.mode === 'resize') {
- const dx = p.x - drag.lastX;
- const dy = p.y - drag.lastY;
- drag.lastX = p.x;
- drag.lastY = p.y;
- setAnnotations((prev) => prev.map((a) => (a.id === drag.id ? resizeAnnotation(a, drag.handle, dx, dy) : a)));
+ const next = annotationsRef.current.map((a) => {
+ if (a.id !== drag.id) return a;
+ return drag.mode === 'move' ? moveAnnotation(a, dx, dy) : resizeAnnotation(a, drag.handle, dx, dy);
+ });
+ setAnnotations(next);
+ const moved = next.find((a) => a.id === drag.id);
+ if (moved) {
+ const b = annotationBounds(moved);
+ setAnchor({ x: b.x + b.width / 2, y: b.y + b.height });
+ }
return;
}