Scott/link click chart select#419
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a card focusing mechanism that adjusts the camera zoom and position to keep both the source and target cards in view when a focus target is set. It integrates this behavior into the AtlasProvider and updates the AtlasStore to manage the focus target state, while also refactoring the store to reduce duplication using a new removeNode helper. Feedback on these changes suggests correcting a comment mismatch regarding the zoom cap percentage, simplifying shape ID handling by casting directly to TLShapeId instead of redundantly parsing the prefix, and refactoring the asynchronous afterCreate handler registration to prevent potential reference errors or memory leaks.
beets
left a comment
There was a problem hiding this comment.
Thanks for the update Scott!
The code looks great, but I have some concerns around the zoom behavior. My expectations when interacting is the zoom / scroll behavior will be the minimal movement required to get the source and selected card in frame, not the midpoint of the two.
In this example, I expected the canvas the selected card to be on the bottom left, not middle of the screen (which is quite different from the behavior when the right card is selected).
I wonder if the behavior should be updated to also account the currently selected card or the last added card, and we compute the midpoint of all three. Or other ideas to minimize the scroll.
Screen.Recording.2026-07-21.at.10.25.09.PM.mov
Could you upload this PR to dev so we can play with it more? I've also just approved all open PRs, so it would be nice to get a snapshot of all the latest code there. /cc @miss-o-soup
ff4d52e to
91c3f6c
Compare
…ather than creating another chart
…in view, instead of centering on chart when panning, zoom out a bit and center on the bounds of the card with the link and the chart
91c3f6c to
4c3484d
Compare
|
@beets thanks for that feedback it made me rethink & it feels much nicer now! I updated so the minimum possible animation is used to get the newly selected card on screen -- It's live on .foo so let me know what you think! |
Overview
When a user clicks a link on a card to create a chart, the atlas now intelligently handles the case where the chart already exists — instead of duplicating it, the camera pans to bring the existing chart into view alongside the source card. Additionally, the pan/zoom behavior when focusing a card pair has been refined: if the target chart is already fully visible no camera animation occurs, and when panning is needed the camera zooms out to frame both the source card and the chart together rather than simply centering on the chart.
Changes Made
focusTargetstate to the atlas store to track which card pair (source + target) should be focusedcardRegisterChartis called for an already-existing chart (or a generic chart already showing the same variable), setfocusTargetto pan to it instead of creating a duplicateregister_card_focus.ts— a new atlas side-effect that watchesfocusTargetand moves the camera to frame both the source and target cards (usingzoomToBoundswith a capped zoom level), or waits for the shape to appear if it hasn't been created yetFOCUS_ZOOM_DISPLAY_CAPconfig constant (125%) to prevent the camera from zooming in too far when both cards are close togetherresolveGridandcanFitWithinZoomCapfromregister_card_placement.tsfor reuse in the focus logicqueryCancelandnodeDismissFollowUpinto a sharedremoveNodehelper