Does anyone know if <this> exists for LazyColumn w...
# compose-android
h
Does anyone know if this exists for LazyColumn when scrolling up/down with long press?
or what would be the alternative of this function for LazyListState
Copy code
fun LazyListState.gridItemKeyAtPosition(hitPoint: Offset): Int? =
        layoutInfo.visibleItemsInfo.find { itemInfo ->
            //todo itemInfo.size.toIntRect().contains(hitPoint.round() - itemInfo.offset)
        }?.key as? Int
b
That same function would work for LazyColumn
I think you could probably just apply the whole post as is to a column instead of a grid
h
Hey Ben, it doesn't work because size is not an offset, rather an int and I cannot find any documentation how to calculate this for a lazy column
b
So that size is your height, you can assume it's within the width of your item because the items take the full width. It will be something like 'hitPoint >= itemInfo.offset && hitPoint < itemInfo.offset + itemInfo.size'
h
you mean something like this
Copy code
.firstOrNull { lazyListItemInfo ->
                hitPoint.y.toInt() in lazyListItemInfo.offset..lazyListItemInfo.offset + lazyListItemInfo.size }
?