fix: two-finger pinch zoom and pan on touch screens#6
Merged
RohitRajendran merged 2 commits intomainfrom Mar 22, 2026
Merged
Conversation
Handle native TouchEvents for two-finger gestures so pinch-to-zoom and two-finger pan work on actual touch screens. The previous wheel-based handler only covered trackpad gestures. Guards on pointer handlers prevent accidental drawing actions during touch navigation. - Add touch event listeners (touchstart/move/end) with pinch-zoom math that mirrors the existing trackpad zoom (midpoint anchored in world space) - Add touch-action:none on the canvas div to suppress browser native gestures - Expose data-zoom/pan-x/pan-y attributes for test observability - Add E2E tests covering pinch-in, pinch-out, pan, and no accidental wall placement
✅ Deploy Preview for snapdraftfloorplans ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Root cause: Konva repaints its hit canvas asynchronously via requestAnimationFrame after React commits. Clicking within that frame window caused the hit test to read the old hit canvas (no elements), landing on the stage background instead of the restored box. The fix adds a data-element-count attribute to the canvas div (set during React's render phase, synchronized with Konva node creation) and waits for both: the attribute to reflect the restored count, then one requestAnimationFrame to let Konva finish painting the hit canvas. This was a pre-existing failure on main (present since commit 64df94f).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TouchEventlisteners on the canvas container now handle two-finger pinch-to-zoom and pan on iPad/touch screensonWheelhandler only covered trackpad pinch (which fires wheel events); actual touch screens were unhandledtouch-action: noneon the canvas div prevents browser-native scroll/zoom from conflictingTechnical details
touchstart(2 fingers): captures initial zoom, pan, finger distance, and midpoint; clears any in-progress single-finger actiontouchmove(2 fingers): computes new zoom from pinch ratio and keeps the pinch midpoint anchored in world space (same math as the existing trackpad zoom handler)touchend: clears gesture state with a 50 ms delay so the finger-lift isn't misread as a tapdata-zoom/data-pan-x/data-pan-yattributes to the canvas div for test observabilityTest plan
touch-action: noneis applied to the canvas container