Skip to content

Commit 65a447c

Browse files
committed
Fix: Scroll does not work correctly when zooming and then resizing the window
1 parent e901604 commit 65a447c

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## v1.3.0 (dd-mm-yyyy)
8+
9+
##### 🚀 New Features
10+
11+
##### 🐛 Bug Fixes
12+
13+
- Scroll does not work correctly when zooming and then resizing the window
14+
715
## [v1.2.0](https://github.com/ollm/OpenComic/releases/tag/v1.2.0) (29-03-2024)
816

917
##### 🚀 New Features

scripts/reading.js

+40
Original file line numberDiff line numberDiff line change
@@ -2043,6 +2043,45 @@ function applyScale(animation = true, scale = 1, center = false, zoomOut = false
20432043
}
20442044
}
20452045

2046+
function zoomScrollHeight()
2047+
{
2048+
if(scalePrevData.scale != 1 && config.readingGlobalZoom && readingViewIs('scroll'))
2049+
{
2050+
let contentRight = template._contentRight();
2051+
let readingBody = contentRight.querySelector('.reading-body');
2052+
let readingBodyChild = readingBody.firstElementChild;
2053+
2054+
let content = contentRight.firstElementChild;
2055+
2056+
let newRect = readingBody.getBoundingClientRect();
2057+
let childRect = readingBodyChild.getBoundingClientRect();
2058+
originalRectReadingBody = content.getBoundingClientRect();
2059+
2060+
let diff = childRect.height / originalRect2.height;
2061+
2062+
originalRect = {
2063+
width: diff * originalRect.width,
2064+
height: diff * originalRect.height,
2065+
left: newRect.left,
2066+
top: newRect.top,
2067+
};
2068+
2069+
originalRect2 = {
2070+
width: originalRect.width,
2071+
height: childRect.height,
2072+
left: newRect.left,
2073+
top: newRect.top,
2074+
};
2075+
2076+
if(!readingBody.classList.contains('zooming'))
2077+
{
2078+
dom.this(contentRight).find('.reading-body').css({
2079+
height: childRect.height+'px',
2080+
});
2081+
}
2082+
}
2083+
}
2084+
20462085
// Zoom in
20472086
function zoomIn(animation = true, center = false)
20482087
{
@@ -2551,6 +2590,7 @@ async function resized()
25512590
if(!readingIsEbook)
25522591
{
25532592
disposeImages();
2593+
zoomScrollHeight();
25542594
calculateView();
25552595
stayInLine(true);
25562596
}

0 commit comments

Comments
 (0)