Created
December 4, 2024 07:44
-
-
Save shoaibmushtaq25/6b440f40095d6f0c8699cf21d5c8b436 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
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