aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-02-11 01:21:12 +0100
committerdec05eba <dec05eba@protonmail.com>2022-02-11 01:21:12 +0100
commit224a38f931e24ffad8c99c5b02fd8939783de852 (patch)
tree44824be0799756a55ec4cea9f2b91b38bbff8aa4 /src
parenta3eb2a9d6315f8a953f7dee72ebe4d17a4b9d42e (diff)
Fix image viewer scrolling to bottom if some pages are larger than window size
Diffstat (limited to 'src')
-rw-r--r--src/ImageViewer.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp
index fcc3b3b..c18ba92 100644
--- a/src/ImageViewer.cpp
+++ b/src/ImageViewer.cpp
@@ -207,10 +207,13 @@ namespace QuickMedia {
window_size.y = window_size_i.y;
window_size_set = true;
- for(int i = 0; i < current_page; ++i) {
- const mgl::vec2d size = get_page_size(i);
- scroll -= size.y;
- page_size[i].prev_size = size;
+ for(int i = 0; i < num_pages; ++i) {
+ const mgl::vec2d current_page_size = get_page_size(i);
+ const double scroll_diff = current_page_size.y - page_size[i].prev_size.y;
+ page_size[i].prev_size = current_page_size;
+
+ if(i < current_page)
+ scroll -= scroll_diff;
}
scroll -= (get_page_size(current_page).y * 0.5 - window_size.y * 0.5);