From f4a5b0c683915889cbc862e8a93a3cd81149a3c9 Mon Sep 17 00:00:00 2001 From: locphamtran Date: Thu, 10 Sep 2026 17:15:36 +0700 Subject: [PATCH] fix(wm): let the library editor pinch a watermark mark onLibTouchStart only recorded the pinch baseline when both fingers arrived in the same touch-start, so a second finger landing later (the normal case) left wmPinchRef null and the move handler scaled nothing -- pinch-the-mark worked on the camera viewfinder but not on a library photo. Seed the baseline in the move handler, as the camera path already does. --- src/components/Viewfinder.tsx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/components/Viewfinder.tsx b/src/components/Viewfinder.tsx index 47ea4aa..8afc95f 100644 --- a/src/components/Viewfinder.tsx +++ b/src/components/Viewfinder.tsx @@ -1349,7 +1349,25 @@ const Viewfinder = forwardRef(function Viewfi // WATERMARK tab open: two fingers scale the mark under them (or do // nothing) — the photo itself only zooms once the editor is closed. if (ts.length >= 2 && wmEditing) { - const p = wmPinchRef.current; + // The second finger normally lands on its own, so the START handler never + // saw the pair and wmPinchRef is still null -- which is why pinching a + // mark worked on the camera (that path seeds here) but not in the library + // editor. Seed the baseline the same way. + let p = wmPinchRef.current; + if (!p) { + const tgt = wmTargetAt( + (ts[0].locationX + ts[1].locationX) / 2, + (ts[0].locationY + ts[1].locationY) / 2 + ); + if (tgt) { + p = { + tgt, + d: Math.hypot(ts[0].locationX - ts[1].locationX, ts[0].locationY - ts[1].locationY), + size: wmSizeOf(tgt), + }; + wmPinchRef.current = p; + } + } if (p) { const d = Math.hypot(ts[0].locationX - ts[1].locationX, ts[0].locationY - ts[1].locationY); applyWmScale(p.tgt, (p.size * d) / Math.max(p.d, 1));