Add scroll-to-node and zoom features#83
Conversation
|
nice! I had a version of pinch to zoom working, but didnt get it to a place where patching / wireing nodes up worked while zoomed out. Does your work solve the coordinate transforms for that to work? Nice stuff! |
|
It does solve the coordinate transforms by only applying the scale effect to the root view. Of course when you're too far zoomed out you won't hit the hitbox. Went through a couple iterations before that and had the same issue, but this version seems to have solved it in my testing. Screen.Recording.2025-11-15.at.8.45.58.PM.mov |
|
It does have that offset / stutter though when the magnification gesture initiates, as seen in the recording... been wrestling with that and SwiftUI but haven't gotten it better than this. Still a starting point in the right direction and nice to have building out larger files. |
|
One of the stutter/ scroll issues is due to use of @\environment, which ive been meaning to factor out. Apparently @\environment cascades recalculations through the view tree, stopping some optimization from happening that the new @\Observable mechanisms support. #66 has a link to a newer Apple video espousing some advice for optimizing some view redraw logic. Nice stuff with the coordinate transform just working!! |
|
Oh interesting, good to know. I'll check that out 👍🏻 |
Addresses feedback from Fabric-Project#83 regarding zoom stutter caused by @Environment observation cascades. Marks Graph drag preview properties as @ObservationIgnored to prevent view recalculation during gestures. Calculates zoom anchor from current scroll position instead of gesture location to eliminate jumps between magnification gestures. Related: Fabric-Project#83, Fabric-Project#66
Addresses feedback from Fabric-Project#83 regarding zoom stutter caused by @Environment observation cascades. Marks Graph drag preview properties as @ObservationIgnored to prevent view recalculation during gestures. Calculates zoom anchor from current scroll position instead of gesture location to eliminate jumps between magnification gestures. Related: Fabric-Project#83, Fabric-Project#66
Addresses feedback from Fabric-Project#83 regarding zoom stutter caused by @Environment observation cascades. Marks Graph drag preview properties as @ObservationIgnored to prevent view recalculation during gestures. Calculates zoom anchor from current scroll position instead of gesture location to eliminate jumps between magnification gestures. Related: Fabric-Project#83, Fabric-Project#66
Addresses feedback from Fabric-Project#83 regarding zoom stutter caused by @Environment observation cascades. Marks Graph drag preview properties as @ObservationIgnored to prevent view recalculation during gestures. Calculates zoom anchor from current scroll position instead of gesture location to eliminate jumps between magnification gestures. Related: Fabric-Project#83, Fabric-Project#66
1: Adds pinch-to-zoom (two-finger magnify gesture)
Screen.Recording.2025-11-15.at.8.39.17.PM.mov
The SwiftUI Canvas + ScrollView is notorious to get the pinch magnification right but this is a first-step and adds value where it's at.
2: Scrolls to first node when opening a project.
Problem: When opening a project, it doesn't scroll to the first node. Test it with this example:
Test Sphere.zip
Before: Project opens in top left corner, lost in the canvas, have to scroll all the way to center to find nodes.
After: The ScrollView automatically scrolls to the nodes