From 380ade89b4a3b90a9023b46ae02823636091ceed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Cla=C3=9Fen?= Date: Fri, 11 Nov 2022 03:55:34 +0100 Subject: [PATCH] Fix incorrect item detection when using content padding --- .../kotlin/org/burnoutcrew/reorderable/ReorderableState.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableState.kt b/reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableState.kt index a6b06f5..abc015b 100644 --- a/reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableState.kt +++ b/reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableState.kt @@ -91,8 +91,10 @@ abstract class ReorderableState( .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