feat(chart): pin the live edge - flick to leave, pull back on every step - #544
Merged
Merged
Conversation
A live chart used to leave the live edge on any horizontal drag past 20% of the plot width, rejoined only when the button came up within 5% of now, and let a pan walk a whole window into empty future. Leaving live now takes a flick toward history: 1.9 logical px/ms over a 50 ms window, and the drag has to carry the chart past the rejoin radius plus 16 px before it lets go, so the pull-back does not catch it on the next pixel. A slower drag pans price only and time keeps following. The pull-back runs inside ChartView::pan_x_px on every step that moves toward now, for drags and Shift-wheel alike, instead of once on mouse-up; a step away from now never rejoins. The radius is max(5% of the plot width, 40 px). A pan stops at now. A framed interval already ahead may come back but not go further, so clamp_future_anchor stays for that case only. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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 & why
Navigating away from the live edge felt loose in three ways:
ANCHOR_BREAK_PCT, floor 32 px) detached the chart, so a drag meant to move price often unhooked time as well.snap_to_live_if_nearinChartInput::mouse_button), so the chart never caught while you were dragging back toward now.The live edge now behaves like a pin:
LiveHoldinchartdx/input.rs). The drag then has to carry the chart past the rejoin radius plus 16 px before it lets go, and at that moment the chart jumps to where the pointer is.ChartView::pan_x_pxrejoins live on any step that moves toward now and ends inside the radius — drags and Shift-wheel alike. Zoom keeps its own existing check. The mouse-up check is gone.max(5% of plot width, 40 px)(ChartView::live_rejoin_px), so a narrow stack pane still has a pull-back worth feeling.Notable decisions
ppp), the radius floor is in device pixels, matching the oldANCHOR_BREAK_MIN_PXconvention in the same layer.clamp_future_anchorstays, now only for a framed interval that ends near now (show_time_rangecan put the anchor slightly ahead). Such a view may pan back but a forward pan does not push it further. Theis_ahead_of_nowbranch that suppressed the 3 s hold for views parked in the future is removed with the feature it served.MANUAL_HOLD_MS), Shift-wheel pan leaving live without a flick, zoom behaviour, and the toolbar's persistent manual mode.ChartInput::mouse_buttonkeeps its signature andboolresult so the four call sites stay as they are; no button transition changes a view now, and this is documented on the method.Known limitations
LIVE_BREAK_SPEED,LIVE_BREAK_WINDOW_MS,LIVE_BREAK_HYSTERESIS_PXinchartdx/input.rs,LIVE_REJOIN_MIN_PXinview.rs.Issues
None of the 17 open issues is touched by this change.
How to verify
fmt
--checkexit 0 · clippy: no new findings — the ones reported inside the touched files (view.rsensure_default_window/update_y, the pre-existing 8-argumentwheel/mouse_buttonsignatures,market.rs) are in code this PR does not change · tests: moon-chart 135 passed, moon-ui-gpui 1805 passed + theme_contract 331 passed, 0 failed.New and reworked tests:
chartdx/input/tests.rs(new, 6): a slow drag never leaves live; a flick leaves once it clears the pull-back; one coarse event after a pause is not a flick; a fast vertical drag is not a flick; a flick toward the future does not break live; the break speed scales with the display.view/tests.rs: a pan stops at the live edge (from live, from history, with Live off, and for a framed view ahead); a step toward now rejoins inside the radius; a step away never rejoins; the radius keeps its pixel floor on a narrow pane. The future-ceiling and zoom tests now start from a framed view parked ahead instead of a forward pan; the two tests that only covered the hold timer for views panned into the future are removed.🤖 Generated with Claude Code