rememberTimelineState

fun rememberTimelineState(duration: Duration, viewportWidthPx: Float, tileWidthPx: Int, zoom: TimelineZoom? = null, listState: LazyListState = rememberLazyListState()): TimelineState(source)

Remembers a TimelineState over duration.

zoom left null fits the whole duration into viewportWidthPx, and refits once viewportWidthPx has held a new width for a moment, so the strip fills it after a rotation or a window resize. A width still changing keeps the zoom and the tile positions it has, along with the frames decoded for them, and the strip can sit short of or past the viewport until the width settles. A duration too long for the bottom of the ladder stays there and scrolls instead. TimelineState.zoomTo and its neighbours hand the zoom to the user once they move it, and it stays where they put it from then on. Passed non-null instead, zoom stays authoritative on every recomposition and never refits, so a caller who hoists the zoom keeps owning it, and setting it back to null leaves the state at the last one it was given.

The holder is rebuilt when listState, duration or tileWidthPx change, but not when viewportWidthPx does on its own, which is what lets a resize leave a zoom the user set alone. listState stays the same instance across a rebuild, so the strip's scroll position survives it.

Return

State keyed to listState, duration and tileWidthPx, following zoom for as long as it stays non-null.

Parameters

duration

How much source time the timeline covers.

viewportWidthPx

How wide the timeline is drawn. Only read to fit zoom when it is null.

tileWidthPx

How wide one tile is drawn.

zoom

How far in the timeline is drawn, or null to fit duration into viewportWidthPx until the user zooms.

listState

The strip's scroll state.