Commits

shemnon  committed 82440fe

indirect scrolling

  • Participants
  • Parent commits 9b9d379

Comments (0)

Files changed (1)

File src/main/java/touchyfxy/Controller.java

     void scroll(ScrollEvent event) {
         updateScroll(event);
         if (event.isInertia()) {
-            centerInBounds(event.getX(), event.getY(), scrollInertia);
+            double x = event.getX();
+            double y = event.getY();
+            if (!event.isDirect()) {
+                x -= event.getTotalDeltaX();
+                y -= event.getTotalDeltaY();
+            }
+            centerInBounds(x, y, scrollInertia);
             scrollInertia.setOpacity(1.0);
             scrollStart.setOpacity(1.0);
             scrollEnd.setOpacity(1.0);
             scrollFade.playFromStart();
         } else {
-            centerInBounds(event.getX(), event.getY(), scrollEnd);
+            double x = event.getX();
+            double y = event.getY();
+            if (!event.isDirect()) {
+                x -= event.getTotalDeltaX();
+                y -= event.getTotalDeltaY();
+            }
+            centerInBounds(x, y, scrollEnd);
         }
     }
 
     @Override
     void scrollEnd(ScrollEvent event) {
         updateScroll(event);
-        centerInBounds(event.getX(), event.getY(), scrollEnd);
+        double x = event.getX();
+        double y = event.getY();
+        if (!event.isDirect()) {
+            x -= event.getTotalDeltaX();
+            y -= event.getTotalDeltaY();
+        }
+        centerInBounds(x, y, scrollEnd);
         scrollFade.playFromStart();
     }
 
     void scrollStart(ScrollEvent event) {
         updateScroll(event);
 
-        centerInBounds(event.getX(), event.getY(), scrollStart);
-        centerInBounds(event.getX(), event.getY(), scrollEnd);
+        double x = event.getX();
+        double y = event.getY();
+
+        centerInBounds(x, y, scrollStart);
+
+        if (!event.isDirect()) {
+            x -= event.getTotalDeltaX();
+            y -= event.getTotalDeltaY();
+        }
+        centerInBounds(x, y, scrollEnd);
         scrollFade.stop();
         scrollFade.jumpTo(Duration.ZERO);
 
         scrollStart.setOpacity(1.0);
         scrollEnd.setOpacity(1.0);
         scrollInertia.setOpacity(0.0);
-
     }
 
     private void updateScroll(ScrollEvent event) {