mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-05 10:58:23 +00:00
Fix scrollbar crash when container is shorter than min thumb height
coerceIn(10dp..height) throws IllegalArgumentException when the drawn height is below 10dp (e.g. 0 during a sheet animation). Skip drawing at zero height and cap the minimum thumb height at the container height. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CSFYvnepFMHdUqYc3SzXVC
This commit is contained in:
@@ -18,13 +18,13 @@ fun Modifier.verticalScrollbar(
|
||||
Modifier.drawWithContent {
|
||||
drawContent()
|
||||
|
||||
if (state.maxValue > 0) {
|
||||
val height = size.height
|
||||
if (state.maxValue > 0 && height > 0f) {
|
||||
val width = size.width
|
||||
val height = size.height
|
||||
|
||||
val scrollFraction = state.value.toFloat() / state.maxValue.toFloat()
|
||||
val scrollbarHeight = (height * height / (state.maxValue + height))
|
||||
.coerceIn(10.dp.toPx()..height)
|
||||
.coerceIn(10.dp.toPx().coerceAtMost(height)..height)
|
||||
|
||||
val scrollableHeight = height - scrollbarHeight
|
||||
val scrollbarY = scrollableHeight * scrollFraction
|
||||
|
||||
Reference in New Issue
Block a user