fix: scroll only until text exits screen

Was scrolling an extra container-width of invisible distance after the
text had already left the screen, adding ~11s of dead time. Now scrolls
to -textWidthPx (text just off-screen) instead of -(textWidthPx +
containerWidthPx).

Made-with: Cursor
This commit is contained in:
cottongin
2026-03-18 05:18:53 -04:00
parent 600687ab56
commit d5dc2d81bd

View File

@@ -473,8 +473,7 @@ private fun TickerText(
if (overflowPx > 0f) { if (overflowPx > 0f) {
key(text) { key(text) {
val velocityPxPerMs = with(density) { velocityDpPerSecond.dp.toPx() } / 1000f val velocityPxPerMs = with(density) { velocityDpPerSecond.dp.toPx() } / 1000f
val totalScrollPx = textWidthPx + containerWidthPx val scrollMs = (textWidthPx / velocityPxPerMs).toInt()
val scrollMs = (totalScrollPx / velocityPxPerMs).toInt()
val offset = remember { Animatable(0f) } val offset = remember { Animatable(0f) }
val alpha = remember { Animatable(0f) } val alpha = remember { Animatable(0f) }
@@ -487,7 +486,7 @@ private fun TickerText(
while (true) { while (true) {
offset.animateTo( offset.animateTo(
-totalScrollPx, -textWidthPx,
tween(scrollMs, easing = LinearEasing) tween(scrollMs, easing = LinearEasing)
) )
offset.snapTo(0f) offset.snapTo(0f)