Skip to content

Commit 94d74bb

Browse files
brysonPaulBryson Paul
andauthored
Adds yields to animations to ensure subcompositions during composition n errors do not occur, and lowers timeout to leave skimming mode. (#2696)
* Adds yields to animations to ensure subcompositions during composition errors do not occur, and lowers timeout to leave skimming mode. --------- Co-authored-by: Bryson Paul <brysonpaul@google.com>
1 parent cf8b230 commit 94d74bb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compose-layout/src/main/java/com/google/android/horologist/compose/layout/m3/FastScrollingTransformingLazyColumn.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import kotlinx.coroutines.CoroutineScope
7575
import kotlinx.coroutines.Job
7676
import kotlinx.coroutines.delay
7777
import kotlinx.coroutines.launch
78+
import kotlinx.coroutines.yield
7879
import kotlin.math.abs
7980

8081
/**
@@ -176,6 +177,7 @@ public fun FastScrollingTransformingLazyColumn(
176177
// We run animateScrollBy with a movement of 0 just to remove the timeText from the screen and
177178
// show the position indicators, as animateScrollToItem will fling from each section.
178179
state.animateScrollBy(0f)
180+
yield()
179181
state.scrollToItem(headers[currentSectionIndex].index, offset)
180182
}
181183
}
@@ -288,6 +290,7 @@ public fun FastScrollingTransformingLazyColumn(
288290
// show the position indicators. Running animateScrollBy by the verticalScrollPixels
289291
// does not scroll as much as scrollBy for some reason.
290292
state.animateScrollBy(0f)
293+
yield()
291294
state.scrollBy(verticalScrollPixels)
292295
}
293296
}
@@ -433,5 +436,5 @@ private object Constants {
433436
const val FIRST_SCROLL_TIMEOUT = 500L
434437
const val RSB_SPEED_THRESHOLD = 40
435438
const val RSB_THROTTLE = 150
436-
const val RSB_SKIMMING_TIMEOUT = 2500L
439+
const val RSB_SKIMMING_TIMEOUT = 1500L
437440
}

0 commit comments

Comments
 (0)