diff --git a/CHANGELOG.md b/CHANGELOG.md
index caca9f295a7..172492abf17 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,6 +24,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We added the possibility to redownload files that had been present but are no longer in the specified location. [#10848](https://github.com/JabRef/jabref/issues/10848)
- We added the citation key pattern `[camelN]`. Equivalent to the first N words of the `[camel]` pattern.
- We added ability to export in CFF (Citation File Format) [#10661](https://github.com/JabRef/jabref/issues/10661).
+- We added the ability to zoom in and out in the document viewer using Ctrl + Scroll. [#10964](https://github.com/JabRef/jabref/pull/10964)
### Changed
diff --git a/src/main/java/org/jabref/gui/documentviewer/DocumentViewerControl.java b/src/main/java/org/jabref/gui/documentviewer/DocumentViewerControl.java
index 75709e4f28b..03b46392267 100644
--- a/src/main/java/org/jabref/gui/documentviewer/DocumentViewerControl.java
+++ b/src/main/java/org/jabref/gui/documentviewer/DocumentViewerControl.java
@@ -14,6 +14,7 @@
import javafx.scene.control.ProgressIndicator;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
+import javafx.scene.input.ScrollEvent;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.Rectangle;
import javafx.util.Duration;
@@ -76,6 +77,16 @@ public void show(DocumentViewModel document) {
flow.estimatedScrollYProperty().addListener((observable, oldValue, newValue) -> scrollY.setValue(newValue));
scrollY.addListener((observable, oldValue, newValue) -> flow.estimatedScrollYProperty().setValue((double) newValue));
flow.totalLengthEstimateProperty().addListener((observable, oldValue, newValue) -> scrollYMax.setValue(newValue));
+ flow.addEventFilter(ScrollEvent.SCROLL, (ScrollEvent event) -> {
+ if (event.isControlDown()) {
+ event.consume();
+ if (event.getDeltaY() > 0) {
+ changePageWidth(100);
+ } else {
+ changePageWidth(-100);
+ }
+ }
+ });
}
private void updateCurrentPage(ObservableList visiblePages) {
@@ -128,7 +139,16 @@ private void updateSizeOfDisplayedPages() {
public void changePageWidth(int delta) {
// Assuming the current page is A4 (or has same aspect ratio)
- setPageWidth(desiredPageDimension.getWidth(Math.sqrt(2)) + delta);
+ int newWidth = desiredPageDimension.getWidth(Math.sqrt(2)) + delta;
+ // Limit zoom out to ~1 page due to occasional display errors when zooming out further
+ int minWidth = (int) (flow.getHeight() / 2 * Math.sqrt(2));
+ if (newWidth < minWidth) {
+ if (newWidth - delta == minWidth) { // Attempting to zoom out when already at minWidth
+ return;
+ }
+ newWidth = minWidth;
+ }
+ setPageWidth(newWidth);
}
/**