Commit Graph

4 Commits

Author SHA1 Message Date
schroda
7145c33fbb Preserve current page on reader width change only when necessary
The pages only change in size with specific "page scale modes".
Thus, if these modes are not active, the scroll position will not be lost.

There are different cases were even with these modes active, the scroll position won't get lost (e.g. "fit width" while no page is larger than the available width), but handling these would be too cumbersome.

Ideally the relative scroll position would be preserved, however, from testing a little that seems to not work too well
2025-03-27 19:49:53 +01:00
Constantin Piber
541eeb0445 Reader preserve current page on window resize (#905)
* Reader: Reset bounds on window size change

19f2d993 introduced a `minWidth` to make sure sizes are consistent over
chapter changes (or when images load later), but when the window itself
changes, this makes the reader incorrectly sized

* Reader: Update size on navbar width change

This happens mostly when the bar is pinned; same effect as previous
commit

* Reader: Attempt to set the page on resize

It's not perfect, but not changing position at all seems impossible due
to how resizes are handled by the browser (since we adjust our content
to the window size)

* Simplify and abstract reader size reset

Co-authored-by: schroda <50052685+schroda@users.noreply.github.com>

* fix: Reader page full width was not properly calculated for static navbar

Only relevant for Fit Content, this did not properly consider the navbar
when the user clamps the content to a custom width

* Refactor: Put reader min sizes to reader itself instead of chapter

This allows some logic simplification.
The `ResizeObserver` can needs to be on an element without restrictions;
previously, the observer would not see the chapter elements get smaller,
since the `min-width` prevented it from shrinking. By applying to the
outer element, we still preserve the centering (since `margin: auto` is
also applied here), but allow the chapter itself to be smaller.

* Reader: Only scroll in continuous reading modes

* Reader: clean up size tracking

Co-authored-by: schroda <50052685+schroda@users.noreply.github.com>

* Fixup previous commit stupidness

* Reader: move `minWidth`/`minHeight` back to chapter wrapper

* Apply suggestions from code review

Co-authored-by: schroda <50052685+schroda@users.noreply.github.com>

* Also revert `fullWidth` calculation

* Simplify `chapterViewerSize`

Co-authored-by: schroda <50052685+schroda@users.noreply.github.com>

* Move size logic entirely to hook

---------

Co-authored-by: schroda <50052685+schroda@users.noreply.github.com>
2025-03-24 23:45:06 +01:00
Constantin Piber
c9c1b8625a Reader preserve current page on reader mode change (#906)
* Reader: Re-scroll on reader mode change

* Simplify reading mode restore

https://github.com/Suwayomi/Suwayomi-WebUI/pull/906#discussion_r2009147119

Co-authored-by: schroda <50052685+schroda@users.noreply.github.com>

* Move effect as per suggestion

Co-authored-by: schroda <50052685+schroda@users.noreply.github.com>

---------

Co-authored-by: schroda <50052685+schroda@users.noreply.github.com>
2025-03-24 23:24:36 +01:00
schroda
a85e5584c8 Preserve scroll position continuous pager on previous chapter load
In the horizontal pager loading the previous chapter caused the scroll position to get lost and instead of starting at the end of the previous chapter, the scroll position was at the very start.
This happened everytime no matter if the scroll position was at the x 0 or not before the previous chapter got visible.

Same issue can be observed in the vertical pager in case the scroll position is at y 0 before the previous chapter has been rendered.
2025-02-19 16:43:58 +01:00