Skip to content

Instantly share code, notes, and snippets.

@shoaibmushtaq25
Created December 4, 2024 07:44
Show Gist options
  • Save shoaibmushtaq25/6b440f40095d6f0c8699cf21d5c8b436 to your computer and use it in GitHub Desktop.
Save shoaibmushtaq25/6b440f40095d6f0c8699cf21d5c8b436 to your computer and use it in GitHub Desktop.
...
var headerOffset: Float by mutableFloatStateOf(0f)
private set
var progress: Float by mutableFloatStateOf(1f)
private set
...
override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {
...
val newOffset = headerOffset + delta
val previousOffset = headerOffset
val heightDelta = -(maxHeight - minHeight)
headerOffset = if (heightDelta > 0) 0f else newOffset.coerceIn(heightDelta, 0f)
progress = 1f - headerOffset / -maxHeight
val consumed = headerOffset - previousOffset
return Offset(0f, consumed)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment