fix(dataZoom): allow wheel zoom-out to expand a collapsed inside dataZoom range#21641
Open
JamesGoslings wants to merge 1 commit into
Open
Conversation
…Zoom range. close apache#21541 When the toolbox dataZoom feature brushes a single category on a category axis, it dispatches startValue === endValue and AxisProxy collapses the percent window to a zero-width range (e.g. [33.33, 33.33] for category index 1 of 4). InsideZoomView.zoom expands the window multiplicatively around the wheel anchor: range[i] = (range[i] - percentPoint) * scale + percentPoint For a collapsed range every term is zero, so wheel-out leaves the range unchanged and the user is stuck looking at the single category they brushed. Detect the collapsed-range case in the zoom handler. When the user is wheel-zooming out (scale > 1), seed the range with a small percent (currently 5%) centered on the wheel anchor before applying the multiplicative expansion. Wheel-in is intentionally left as a no-op on a collapsed range — it cannot collapse the range further. Adds unit coverage for the collapsed-range expand, the collapsed no-op on wheel-in, the unchanged behavior on a non-degenerate range, and the [0, 100] clamp at the edge. Adds a visual reproducer matching the steps in the issue.
|
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. |
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.
Brief Information
This pull request is in the type of:
What does this PR do?
Make
dataZoom insidewheel zoom-out work after the toolbox has collapsed the range to a single category, so users can zoom back out and see all categories again.Fixed issues
Details
Before: What was the problem?
When the toolbox dataZoom feature brushes a single category on a category axis, it dispatches
startValue === endValueandAxisProxycollapses the percent window to a zero-width range (for example[33.33, 33.33]for category index1of4).InsideZoomView.zoomexpands the window multiplicatively around the wheel anchor:For a collapsed range every term is zero, so wheel-out leaves the range unchanged and the user is stuck looking at the single category they brushed. The bug was confirmed by @helgasoft and tracked in #20392.
Reproducer (from the issue):
After: How does it behave after the fixing?
Detect the collapsed-range case in the zoom handler. When the user is wheel-zooming out (
scale > 1), seed the range with a small percent (currently 5%) centered on the wheel anchor before applying the multiplicative expansion:After the seed, subsequent wheel ticks scale multiplicatively as before, so the user reaches the full range in roughly 30 ticks (default factor 1.1). The seed is anchored on the wheel position, then the existing
sliderMoveclamp ensures the range stays within[0, 100]even when the wheel anchor sits near the edge.Wheel-in on a collapsed range is intentionally left as a no-op — it cannot collapse the range further, and the existing math already handles that correctly.
Tests
test/ut/spec/component/dataZoom/insideZoomViewWheel.test.tsadds four unit tests calling the exportedgetRangeHandlers.zoomdirectly with mocked context:undefined(no change).100%→ seed gets clamped to[0, 100]without crashing.test/dataZoom-wheel-zoom-out-collapsed.htmlis a visual reproducer matching the issue's steps so reviewers can brush a single category in the toolbox and verify the wheel now expands the window.InsideZoomView.tsexportsgetRangeHandlersso the unit tests can drive the handler in isolation; the type aliasDataZoomGetRangeHandlerswas already exported, so this is purely a value export.Full unit suite: 26 suites, 196 tests, all green.
Document Info
Misc
Security Checking
ZRender Changes
Related test cases or examples to use the new APIs
test/ut/spec/component/dataZoom/insideZoomViewWheel.test.ts— unit teststest/dataZoom-wheel-zoom-out-collapsed.html— visual reproducerMerging options
Other information
The seed half-width (2.5% per side, 5% width on first tick) is empirical: small enough not to feel jumpy on the first tick, large enough that the user feels progress and reaches the full range in a reasonable number of ticks. Happy to tune this if reviewers prefer a different value.