Would this only affect how scroll events from the mouse or gestures are
handled, or does it also apply for when you drag the scrollbar?
On 07/09/2026 22:24, Marius Hanl wrote:
I like this idea.
With your proposed interface, is it possible that the complete logic
is handled inside the ScrollTransition, e.g. all the ScrollPane need
to do is call a method on ScrollTransition?
Just wondering how much the ScrollPane need to "know" about the
transitions, so need code to account for that (or maybe for all
possible cases), or the changes are more concentrated on the
ScrollTransition itself and the containers only manage the property
and delegate to it.
-- Marius
On 9/4/26 5:08 PM, Michael Strauß wrote:
Previously, we've improved the JavaFX animation story by making
backgrounds and borders interpolatable, and adding timeline-driven
CSS-based transitions that automatically run when the state of a node
changes.
What's still missing is scroll transitions. A scroll transition is not
triggered by a state change, but by a scroll gesture performed by the
user. It is defined by a new property on VirtualFlow-based controls
(ListView, etc.) and on ScrollPane:
/**
* Specifies the transition used to animate discrete
* mouse-wheel scrolling.
* <p>
* The transition is applied when scrolling occurs in
* discrete wheel steps. It is not applied to fine-grained
* precision scrolling by a touchpad or a high-resolution
* mouse wheel.
*
* @defaultValue {@code null}
* @since 28
*/
private ObjectProperty<ScrollTransition> scrollTransition;
Here's how ScrollTransition is defined:
public sealed interface ScrollTransition
permits ScrollTransition.Spring,
ScrollTransition.ExponentialDecay {
record Spring(double naturalFrequency,
double dampingRatio)
implements ScrollTransition { ... }
record ExponentialDecay(Duration halfLife)
implements ScrollTransition { ... }
}
When a scroll event is encountered that exceeds a continuous-scrolling
threshold, the viewport is animated to its new position as defined by
the ScrollTransition.
Here's how it looks like in action:
https://github.com/user-attachments/assets/edf65b66-3ec3-4495-9c70-9154c586515e
It is probably a good idea to allow scroll transitions be
CSS-styleable. However, this is not a standard CSS property, so we'd
need to invent a JavaFX-specific grammar.
If there is interest in this feature, I can prepare a PR with the
implementation.