Skip to content

Commit

Permalink
Fix incorrect item detection when using content padding
Browse files Browse the repository at this point in the history
  • Loading branch information
aclassen committed Nov 11, 2022
1 parent 062fa92 commit 380ade8
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ abstract class ReorderableState<T>(
.distinctUntilChanged { old, new -> old.firstOrNull()?.itemIndex == new.firstOrNull()?.itemIndex && old.count() == new.count() }

internal open fun onDragStart(offsetX: Int, offsetY: Int): Boolean {
val x = if (!isVerticalScroll) offsetX + viewportStartOffset else offsetX
val y = if (isVerticalScroll) offsetY + viewportStartOffset else offsetY
return visibleItemsInfo
.firstOrNull { offsetX in it.left..it.right && offsetY in it.top..it.bottom }
.firstOrNull { x in it.left..it.right && y in it.top..it.bottom }
?.also {
selected = it
draggingItemIndex = it.itemIndex
Expand Down

0 comments on commit 380ade8

Please sign in to comment.