From 253440844e0867948710449da7b8e482a5f1f1ef Mon Sep 17 00:00:00 2001 From: Glavo Date: Tue, 23 Dec 2025 20:20:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20JFXListView=20=E7=9A=84?= =?UTF-8?q?=E5=B9=B3=E6=BB=91=E6=BB=9A=E5=8A=A8=E6=95=88=E6=9E=9C=20(#5052?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jackhuang/hmcl/ui/ScrollUtils.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) 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();