Skip to content

Commit dc60d65

Browse files
authored
Merge pull request #199 from aclassen/feature/content-padding
Fix incorrect item detection when using content padding
2 parents 062fa92 + 380ade8 commit dc60d65

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableState.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ abstract class ReorderableState<T>(
9191
.distinctUntilChanged { old, new -> old.firstOrNull()?.itemIndex == new.firstOrNull()?.itemIndex && old.count() == new.count() }
9292

9393
internal open fun onDragStart(offsetX: Int, offsetY: Int): Boolean {
94+
val x = if (!isVerticalScroll) offsetX + viewportStartOffset else offsetX
95+
val y = if (isVerticalScroll) offsetY + viewportStartOffset else offsetY
9496
return visibleItemsInfo
95-
.firstOrNull { offsetX in it.left..it.right && offsetY in it.top..it.bottom }
97+
.firstOrNull { x in it.left..it.right && y in it.top..it.bottom }
9698
?.also {
9799
selected = it
98100
draggingItemIndex = it.itemIndex

0 commit comments

Comments
 (0)