ignore scroll events with zero scroll movement

This commit is contained in:
Craig Raw 2024-04-24 09:00:36 +02:00
parent 21d91d3d10
commit f6fd889712
2 changed files with 9 additions and 7 deletions

View file

@ -49,13 +49,15 @@ public class FeeRangeSlider extends Slider {
}); });
setOnScroll(event -> { setOnScroll(event -> {
double newFeeRate = getFeeRate() + (event.getDeltaY() > 0 ? FEE_RATE_SCROLL_INCREMENT : -FEE_RATE_SCROLL_INCREMENT); if(event.getDeltaY() != 0) {
if(newFeeRate < LONG_FEE_RATES_RANGE.get(0)) { double newFeeRate = getFeeRate() + (event.getDeltaY() > 0 ? FEE_RATE_SCROLL_INCREMENT : -FEE_RATE_SCROLL_INCREMENT);
newFeeRate = LONG_FEE_RATES_RANGE.get(0); if(newFeeRate < LONG_FEE_RATES_RANGE.get(0)) {
} else if(newFeeRate > LONG_FEE_RATES_RANGE.get(LONG_FEE_RATES_RANGE.size() - 1)) { newFeeRate = LONG_FEE_RATES_RANGE.get(0);
newFeeRate = LONG_FEE_RATES_RANGE.get(LONG_FEE_RATES_RANGE.size() - 1); } else if(newFeeRate > LONG_FEE_RATES_RANGE.get(LONG_FEE_RATES_RANGE.size() - 1)) {
newFeeRate = LONG_FEE_RATES_RANGE.get(LONG_FEE_RATES_RANGE.size() - 1);
}
setFeeRate(newFeeRate);
} }
setFeeRate(newFeeRate);
}); });
} }

View file

@ -101,7 +101,7 @@ public class QRDisplayDialog extends Dialog<ButtonType> {
stackPane.getChildren().add(qrImageView); stackPane.getChildren().add(qrImageView);
qrImageView.setOnScroll(scrollEvent -> { qrImageView.setOnScroll(scrollEvent -> {
if(animateQRService != null && animateQRService.isRunning()) { if(animateQRService != null && animateQRService.isRunning() && scrollEvent.getDeltaY() != 0) {
Duration duration = animateQRService.getPeriod(); Duration duration = animateQRService.getPeriod();
Duration newDuration = scrollEvent.getDeltaY() > 0 ? duration.multiply(1.1) : duration.multiply(0.9); Duration newDuration = scrollEvent.getDeltaY() > 0 ? duration.multiply(1.1) : duration.multiply(0.9);
if(newDuration.lessThan(Duration.millis(ANIMATION_PERIOD_MILLIS*10)) && newDuration.greaterThan(Duration.millis(ANIMATION_PERIOD_MILLIS/2))) { if(newDuration.lessThan(Duration.millis(ANIMATION_PERIOD_MILLIS*10)) && newDuration.greaterThan(Duration.millis(ANIMATION_PERIOD_MILLIS/2))) {