fix(graph): roam cannot be restarted after panning the graph out of its initial viewport - #21754
Open
gitlilimin wants to merge 1 commit into
Open
gitlilimin wants to merge 1 commit into
gitlilimin wants to merge 1 commit into
Conversation
…/zoom The roam (pan/zoom) trigger area of the graph series was glued to the content layer: GraphView registered the roam controller's isInSelf check as coordinateSystem.containPoint(), which tests the pointer against dataRect transformed by the roam matrix (mtOverall). The trigger area therefore moved along with pan/zoom and could drift partially or completely out of the viewport, leaving dead regions where roam could no longer be started. With force layout dataRect even falls back to viewRect (createView.ts isNaN branch), i.e. a static rect glued to the content layer. Test the pointer against getViewRect() - the layout viewport in the view layer, which excludes the roam transform - and fall back to the previous containPoint() check when no view rect is available.
|
Thanks for your contribution! Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only. To reviewers: If this PR is going to be described in the changelog in the future release, please make sure this PR has one of the following labels: This message is shown because the PR description doesn't contain the document related template. |
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.
What does this PR do?
Fix a bug in the
graphseries where the roam (pan/zoom) trigger area is glued to the content layer instead of the view layer. After the user pans (or zooms) the graph, the area in which a new pan/zoom gesture can be started moves along with the content and can drift partially or completely out of the viewport, leaving "dead" regions where roam no longer responds.Root cause
GraphViewregisters the roam controller'sisInSelfcheck ascoordinateSystem.containPoint([x, y]). InView.containPoint, the test rectangle isdataRecttransformed bymtOverall, which includes the roam transform — so the trigger area itself pans/zooms together with the content.With
forcelayout this is even more confusing: nodes have no initialx/y, sodataRectfalls back toviewRect(createView.ts, theisNaN(aspect)branch), making the trigger area a static rectangle (approximately the container at init, minus the aspect-preserving padding) that only moves with the roam transform.Reproduce
roam: true(e.g. enable roam on the official force layout example).Fix
Test the pointer against
getViewRect()— the layout viewport in the view layer, which does not include the roam transform — instead of the roam-transformeddataRect. Falls back to the previouscontainPointcheck if the coordinate system does not provide a view rect.The existing
roamTrigger: 'global'option is unaffected (it already bypasses this check entirely); this fix makes the default behavior (roamTriggerunset /'self') consistent: the trigger area is the series viewport and no longer drifts with pan/zoom.Test
roam: true): before the fix, after panning, large dead areas appear where pan/zoom gestures are ignored; after the fix, roam can be started anywhere within the chart viewport regardless of previous pan/zoom.npm run lintpasses on the changed file;libbuild (build:lib) compiles.Note: other series that register a similar
containPoint-based check (e.g.tree,sankey) may share the same pattern — happy to follow up if you think it is worth aligning.