-
-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Smooth scrolling #150
base: main
Are you sure you want to change the base?
Smooth scrolling #150
Conversation
I've tested this on a 5000 row JTable (real world application) on Windows 10, haven't seen any issues wither either mouse scrolling or pressing on the scroll bar track. However when holding down the arrows on the scroll bar (I have enabled them), 'smooth scrolling' looks jittery compared to non 'smooth scrolling' |
@grimlock81 thx for your feedback. |
Arrow button scrolling is now less jittery (but not perfect, I think). Smooth scrolling with keyboard is now implemented.
This needs some improvements. Repeating unit (line) scrolling (e.g. hold down |
I am really interest in this feature. I am willing to play with it, test it on our intensive application and eventually experiment code changes if needed. |
I experimented with this smooth-scrolling implementation. I first ported the few changes to the current code because the PR has some conflicts. The result of this port is I tested it on our real world app and found several problems (I am using Windows 10 with Java 17). I then created a self-contained test case ( The root cause of the problems is that calls to Please let me know what you think, if you see the scrolling artifacts I am describing, and if you have some ideas to fix table artifacts with keyboard navigation. Zip file: FlatLaf-smooth-scrolling.zip |
331ab06
to
5bc5c3d
Compare
Sure, I've rebased all commits in this PR to current main branch. Sorry for the delay.
Yes, I see the scrolling artifacts too. Will have a closer look at your PR #683 next week... |
…ng animation is running (issue #50)
…ion is running (issue #50)
…ing" to disable all animations or smooth scrolling via command line (without modifying the application)
…d JEditorPane for testing smooth scrolling
…th Alt+S without moving focus to checkbox; removed unused tree model
…o scrollbar values
- use ChangeListener instead of AdjustmentListener because this is invoked before all other scrollbar listeners (which may run 20-30ms) and avoids a delay in the line chart - use System.nanoTime() instead of System.currentTimeMillis() for better precision - paint vertical lines in chart at every 200ms (was 1sec) - print elapsed time between scrollbar events
…hart using a lighter color
…mouse button) and smooth scrolling enabled
…id" and "Auto-resize mode" check boxes
…h scrolling in case that scroll view does not implement Scrollable interface
…crolling when using mouse-wheel or scroll bar (still occurs when scrolling by moving selection via keyboard) many thanks to @Chrriis for the idea to temporary disable blitting mode on viewport
- added small vertical line to indicate data points in chart - added split pane to allow changing height of components - Alt+C clears chart without moving focus to "Clear" button - separate chart lines for smooth and non-smooth scrolling
5bc5c3d
to
e2e3fd3
Compare
- added slider to horizontally scale chart - improved chart legend - record stack for points in chart and show in tooltip on hover
…g. hold down PageUp key) for Tree, TextArea, TextPane and EditorPane
…e (if smooth scrolling is enabled)
The too slow repeating block (page) scrolling (e.g. hold down PageUp key) for Tree, TextArea, TextPane and EditorPane is fixed in commit 542e7d5 |
- fixed jittery repeating-scrolling with PageUp/Down keys when reaching the top/bottom/left/right of the viewport (see FlatScrollBarUI.setValueAnimated()) - temporary change viewport scroll mode only if it is JViewport.BLIT_SCROLL_MODE - use JViewport.SIMPLE_SCROLL_MODE when temporary disabling blitting
Fixed jittery repeating-scrolling with PageUp/Down keys when reaching the top/bottom/left/right of the viewport in commit c529dcb. Following screenshot shows the difference in the chart, which shows the scrollbar value. Before this change, there were significant gaps in the curve, which resulted in jittery scrolling. |
…or easier use in other test apps
- better list/tree/etc items for easier recognizing jittery scrolling - sliders to modify animation duration and resolution - slider to invoke `scrollRectToVisible()` - option to show row header for table - use viewport.viewPosition for chart (instead of scrollbar.value) - highlight methods in stack of tooltip (e.g. JViewport.setViewPosition())
This PR adds smooth scrolling, as used in modern Web browsers, to FlatLaf. (issue #50)
Instead of simply painting scroll pane content at new view position, smooth scrolling animates the painting so that it looks like the content is "moving" to the new view position.
Please try this with real world applications (on various platforms if possible) and give feedback. Thanks.
Current state:
Smooth scrolling is enabled by default.
Can be disabled for the whole application (at any time) with (e.g. via some Settings dialog):
Or via system property:
Or at command line with:
Can be disabled for single scroll panes (at any time) with:
It is also possible to customize the animation by changing the duration of the scroll animation and the resolution (time between repaints). Both values are in milliseconds. E.g.
Default duration is 200ms and default resolution is 10ms.