diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/ScrollUtils.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/ScrollUtils.java index faf72d8dc..25ca33710 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/ScrollUtils.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/ScrollUtils.java @@ -25,7 +25,6 @@ import javafx.animation.Animation.Status; import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.event.EventHandler; -import javafx.scene.control.IndexedCell; import javafx.scene.control.ScrollPane; import javafx.scene.control.skin.VirtualFlow; import javafx.scene.input.MouseEvent; @@ -226,7 +225,6 @@ final class ScrollUtils { final double[] derivatives = new double[FRICTIONS.length]; Timeline timeline = new Timeline(); - Holder scrollDirectionHolder = new Holder<>(); final EventHandler mouseHandler = event -> timeline.stop(); final EventHandler scrollHandler = event -> { if (event.getEventType() == ScrollEvent.SCROLL) { @@ -234,7 +232,6 @@ final class ScrollUtils { if (scrollDirection == ScrollDirection.LEFT || scrollDirection == ScrollDirection.RIGHT) { return; } - scrollDirectionHolder.value = scrollDirection; double currentSpeed = isTrackPad(event, scrollDirection) ? speed / trackPadAdjustment : speed; derivatives[0] += scrollDirection.intDirection * currentSpeed; @@ -256,15 +253,7 @@ final class ScrollUtils { } double dy = derivatives[derivatives.length - 1]; - - int cellCount = virtualFlow.getCellCount(); - IndexedCell firstVisibleCell = virtualFlow.getFirstVisibleCell(); - double height = firstVisibleCell != null ? firstVisibleCell.getHeight() * cellCount : 0.0; - - double delta = height > 0.0 - ? dy / height - : (scrollDirectionHolder.value == ScrollDirection.DOWN ? 0.001 : -0.001); - virtualFlow.setPosition(Math.min(Math.max(virtualFlow.getPosition() + delta, 0), 1)); + virtualFlow.scrollPixels(dy); if (Math.abs(dy) < 0.001) { timeline.stop();