2525import javafx .animation .KeyFrame ;
2626import javafx .animation .Timeline ;
2727import javafx .event .EventHandler ;
28- import javafx .scene .control .IndexedCell ;
2928import javafx .scene .control .ScrollPane ;
3029import javafx .scene .control .skin .VirtualFlow ;
3130import javafx .scene .input .MouseEvent ;
@@ -226,15 +225,13 @@ private static void smoothScroll(VirtualFlow<?> virtualFlow, double speed, doubl
226225 final double [] derivatives = new double [FRICTIONS .length ];
227226
228227 Timeline timeline = new Timeline ();
229- Holder <ScrollDirection > scrollDirectionHolder = new Holder <>();
230228 final EventHandler <MouseEvent > mouseHandler = event -> timeline .stop ();
231229 final EventHandler <ScrollEvent > scrollHandler = event -> {
232230 if (event .getEventType () == ScrollEvent .SCROLL ) {
233231 ScrollDirection scrollDirection = determineScrollDirection (event );
234232 if (scrollDirection == ScrollDirection .LEFT || scrollDirection == ScrollDirection .RIGHT ) {
235233 return ;
236234 }
237- scrollDirectionHolder .value = scrollDirection ;
238235 double currentSpeed = isTrackPad (event , scrollDirection ) ? speed / trackPadAdjustment : speed ;
239236
240237 derivatives [0 ] += scrollDirection .intDirection * currentSpeed ;
@@ -256,15 +253,7 @@ private static void smoothScroll(VirtualFlow<?> virtualFlow, double speed, doubl
256253 }
257254
258255 double dy = derivatives [derivatives .length - 1 ];
259-
260- int cellCount = virtualFlow .getCellCount ();
261- IndexedCell <?> firstVisibleCell = virtualFlow .getFirstVisibleCell ();
262- double height = firstVisibleCell != null ? firstVisibleCell .getHeight () * cellCount : 0.0 ;
263-
264- double delta = height > 0.0
265- ? dy / height
266- : (scrollDirectionHolder .value == ScrollDirection .DOWN ? 0.001 : -0.001 );
267- virtualFlow .setPosition (Math .min (Math .max (virtualFlow .getPosition () + delta , 0 ), 1 ));
256+ virtualFlow .scrollPixels (dy );
268257
269258 if (Math .abs (dy ) < 0.001 ) {
270259 timeline .stop ();
0 commit comments