mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 06:50:56 +03:00
ScrollBar: fixed jittery scrolling when in repeating mode (hold down mouse button) and smooth scrolling enabled
This commit is contained in:
@@ -477,13 +477,13 @@ public class FlatScrollBarUI
|
|||||||
if( useValueIsAdjusting )
|
if( useValueIsAdjusting )
|
||||||
scrollbar.setValueIsAdjusting( true );
|
scrollbar.setValueIsAdjusting( true );
|
||||||
|
|
||||||
|
int oldValue = scrollbar.getValue();
|
||||||
|
|
||||||
// if invoked while animation is running, calculation of new value
|
// if invoked while animation is running, calculation of new value
|
||||||
// should start at the previous target value
|
// should start at the previous target value
|
||||||
if( targetValue != Integer.MIN_VALUE )
|
if( targetValue != Integer.MIN_VALUE )
|
||||||
scrollbar.setValue( targetValue );
|
scrollbar.setValue( targetValue );
|
||||||
|
|
||||||
int oldValue = scrollbar.getValue();
|
|
||||||
|
|
||||||
r.run();
|
r.run();
|
||||||
|
|
||||||
// do not use animation if started dragging thumb
|
// do not use animation if started dragging thumb
|
||||||
|
|||||||
@@ -558,11 +558,20 @@ public class FlatSmoothScrollingTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One or two values between two equal values are considered "temporary",
|
||||||
|
* which means that they are the target value for the following scroll animation.
|
||||||
|
*/
|
||||||
private boolean isTemporaryValue( List<Data> chartData, int i ) {
|
private boolean isTemporaryValue( List<Data> chartData, int i ) {
|
||||||
if( i == 0 || i == chartData.size() - 1 )
|
if( i == 0 || i == chartData.size() - 1 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return chartData.get( i - 1 ).value == chartData.get( i + 1 ).value;
|
double valueBefore = chartData.get( i - 1 ).value;
|
||||||
|
double valueAfter = chartData.get( i + 1 ).value;
|
||||||
|
|
||||||
|
return valueBefore == valueAfter ||
|
||||||
|
(i < chartData.size() - 2 && valueBefore == chartData.get( i + 2 ).value) ||
|
||||||
|
(i > 1 && chartData.get( i - 2 ).value == valueAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int chartWidth() {
|
private int chartWidth() {
|
||||||
|
|||||||
Reference in New Issue
Block a user