Skip to content

Commit

Permalink
Fix: Scroll does not work correctly when zooming and then resizing th…
Browse files Browse the repository at this point in the history
…e window
  • Loading branch information
ollm committed Mar 31, 2024
1 parent e901604 commit 65a447c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.

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).

## v1.3.0 (dd-mm-yyyy)

##### 🚀 New Features

##### 🐛 Bug Fixes

- Scroll does not work correctly when zooming and then resizing the window

## [v1.2.0](https://github.com/ollm/OpenComic/releases/tag/v1.2.0) (29-03-2024)

##### 🚀 New Features
Expand Down
40 changes: 40 additions & 0 deletions scripts/reading.js
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,45 @@ function applyScale(animation = true, scale = 1, center = false, zoomOut = false
}
}

function zoomScrollHeight()
{
if(scalePrevData.scale != 1 && config.readingGlobalZoom && readingViewIs('scroll'))
{
let contentRight = template._contentRight();
let readingBody = contentRight.querySelector('.reading-body');
let readingBodyChild = readingBody.firstElementChild;

let content = contentRight.firstElementChild;

let newRect = readingBody.getBoundingClientRect();
let childRect = readingBodyChild.getBoundingClientRect();
originalRectReadingBody = content.getBoundingClientRect();

let diff = childRect.height / originalRect2.height;

originalRect = {
width: diff * originalRect.width,
height: diff * originalRect.height,
left: newRect.left,
top: newRect.top,
};

originalRect2 = {
width: originalRect.width,
height: childRect.height,
left: newRect.left,
top: newRect.top,
};

if(!readingBody.classList.contains('zooming'))
{
dom.this(contentRight).find('.reading-body').css({
height: childRect.height+'px',
});
}
}
}

// Zoom in
function zoomIn(animation = true, center = false)
{
Expand Down Expand Up @@ -2551,6 +2590,7 @@ async function resized()
if(!readingIsEbook)
{
disposeImages();
zoomScrollHeight();
calculateView();
stayInLine(true);
}
Expand Down

0 comments on commit 65a447c

Please sign in to comment.