Check for null ItemInfo when reordering
This commit is contained in:
parent
a45270c54a
commit
3364bb9f30
1 changed files with 4 additions and 1 deletions
|
@ -59,7 +59,7 @@ class ReorderingState(
|
||||||
overscrolled = 0
|
overscrolled = 0
|
||||||
itemInfo = lazyListState.layoutInfo.visibleItemsInfo.find {
|
itemInfo = lazyListState.layoutInfo.visibleItemsInfo.find {
|
||||||
it.index == index + extraItemCount
|
it.index == index + extraItemCount
|
||||||
}!!
|
} ?: return
|
||||||
onDragStart.invoke()
|
onDragStart.invoke()
|
||||||
draggingIndex = index
|
draggingIndex = index
|
||||||
reachedIndex = index
|
reachedIndex = index
|
||||||
|
@ -83,6 +83,7 @@ class ReorderingState(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onDrag(change: PointerInputChange, dragAmount: Offset) {
|
fun onDrag(change: PointerInputChange, dragAmount: Offset) {
|
||||||
|
if (!isDragging) return
|
||||||
change.consume()
|
change.consume()
|
||||||
|
|
||||||
val delta = when (lazyListState.layoutInfo.orientation) {
|
val delta = when (lazyListState.layoutInfo.orientation) {
|
||||||
|
@ -163,6 +164,8 @@ class ReorderingState(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onDragEnd() {
|
fun onDragEnd() {
|
||||||
|
if (!isDragging) return
|
||||||
|
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
offset.animateTo((previousItemSize + nextItemSize) / 2)
|
offset.animateTo((previousItemSize + nextItemSize) / 2)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue