mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 22:57:50 +03:00
Update src/activities/reader/EpubReaderActivity.cpp
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
a6fd503f94
commit
17c20db930
@ -253,7 +253,10 @@ void EpubReaderActivity::jumpToPercent(int percent) {
|
|||||||
percent = clampPercent(percent);
|
percent = clampPercent(percent);
|
||||||
|
|
||||||
// Convert percent into a byte-like absolute position across the spine sizes.
|
// Convert percent into a byte-like absolute position across the spine sizes.
|
||||||
size_t targetSize = (bookSize * static_cast<size_t>(percent)) / 100;
|
// Use an overflow-safe computation: (bookSize / 100) * percent + (bookSize % 100) * percent / 100
|
||||||
|
size_t targetSize =
|
||||||
|
(bookSize / 100) * static_cast<size_t>(percent) +
|
||||||
|
(bookSize % 100) * static_cast<size_t>(percent) / 100;
|
||||||
if (percent >= 100 && bookSize > 0) {
|
if (percent >= 100 && bookSize > 0) {
|
||||||
// Ensure the final percent lands inside the last spine item.
|
// Ensure the final percent lands inside the last spine item.
|
||||||
targetSize = bookSize - 1;
|
targetSize = bookSize - 1;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user