Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions app/src/main/java/com/kmworks/kmreader/ui/reader/ReaderScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1911,15 +1911,24 @@ private fun PageImage(
var lastPainter by remember(page.number, half) {
mutableStateOf<androidx.compose.ui.graphics.painter.Painter?>(null)
}
// Ratio this cell settled on once it decoded. Held across a model swap: while the enhanced
// request sits in Loading there is no painter to measure, and re-deriving from page.width/height
// (or the 0.7 fallback when metadata is stale) would resize the box mid-scroll — in a webtoon
// strip that moves the LazyColumn's item height for a frame, which is what reads as "the scroll
// position jumped when the 2x page replaced the source".
var lastRatio by remember(page.number, half) { mutableStateOf<Float?>(null) }
LaunchedEffect(imageState) {
(imageState as? AsyncImagePainter.State.Success)?.let { lastPainter = it.painter }
(imageState as? AsyncImagePainter.State.Success)?.let { state ->
lastPainter = state.painter
state.painter.intrinsicSize
?.takeIf { it.width > 0f && it.height > 0f }
?.let { it.width / it.height }
?.takeIf { it.isFinite() && it > 0f }
?.let { lastRatio = it }
}
}
val decodedRatio = (imageState as? AsyncImagePainter.State.Success)
?.painter?.intrinsicSize
?.takeIf { it.width > 0f && it.height > 0f }
?.let { it.width / it.height }
val metadataRatio = if (page.width > 0 && page.height > 0) page.width.toFloat() / page.height.toFloat() else 0f
val fullRatio = decodedRatio?.takeIf { it.isFinite() && it > 0f }
val fullRatio = lastRatio
?: metadataRatio.takeIf { it.isFinite() && it > 0f }
?: 0.7f

Expand Down