Skip to content

Commit

Permalink
Merge pull request #199 from aclassen/feature/content-padding
Browse files Browse the repository at this point in the history
Fix incorrect item detection when using content padding
  • Loading branch information
aclassen authored Nov 11, 2022
2 parents 062fa92 + 380ade8 commit dc60d65
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 dc60d65

Please sign in to comment.