BREAKING NEWS: this bug is now officially being tracked in the Java bug tracker.

I noticed today that the delta values provided by the JavaFX ScrollEvent object seem to be invalid at the end of the scroll event cycle. The absolute value of those delta values becomes bigger again even though they should end up in values around zero. I ran my tests on a Mac with the Magic Mouse and the Magic Touchpad. The values getting bigger causes stuttering in the UI, for example a swipe scroll inside the ListView will cause the ListView to finish the scrolling with a stutter at the end (see this video).

(Please notice that this is not relevant for mouse wheel scrolling as the mouse wheel will not continuously fire scroll events).

A typical output looks like this:

--- Scroll started ----
7.0001220703125 <-- first the values start to get bigger
10.0
13.000030517578125
12.0001220703125
12.0001220703125
13.000030517578125
12.0001220703125
13.000030517578125
12.0001220703125
11.00006103515625
10.0
9.000091552734375 <-- then the values are going down
9.000091552734375
8.000030517578125
8.000030517578125
7.0001220703125
7.0001220703125
6.00006103515625
6.00006103515625
6.00006103515625 <-- getting closer to zero (all good, normal so far)
14.000091552734375 <-- but now all of a sudden bigger values again
14.000091552734375 <--
13.000030517578125 <--
11.00006103515625 <--

The code below can be used to reproduce this issue. Simply start a scroll gesture with your touchpad or magic mouse on the label inside the window.

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class ScrollBugApp extends Application {

  @Override
  public void start(Stage primaryStage) throws Exception {
      Label label = new Label("Scroll On Me!");
      label.setAlignment(Pos.CENTER);
      label.setOnScrollStarted(evt -> System.out.println("--- Scroll started ----"));
      label.setOnScroll(evt -> System.out.println(evt.getDeltaY()));
      Scene scene = new Scene(label);
      primaryStage.setScene(scene);
      primaryStage.setWidth(200);
      primaryStage.setHeight(200);
      primaryStage.centerOnScreen();
      primaryStage.show();
 }

 public static void main(String
[] args) { launch(args); } }

If anyone knows of a work-around or a way to filter out those freak values at the end then please let me know.