Skip to content

Instantly share code, notes, and snippets.

@linean
Created May 10, 2022 19:53
Show Gist options
  • Save linean/2f58f425f30938f1360f684c17d0dfee to your computer and use it in GitHub Desktop.
Save linean/2f58f425f30938f1360f684c17d0dfee to your computer and use it in GitHub Desktop.
var itemsOffsets by remember { mutableStateOf(mapOf<KEY, ItemOffset>()) }
key(itemKeys) {
itemsOffsets = items.mapIndexed { index, item ->
val key = itemKey(item)
key to when {
itemsOffsets.containsKey(key) -> itemsOffsets.getValue(key)
else -> ItemOffset(gridOffsets[index])
}
}.toMap()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment