Kyant
02/06/2025, 12:06 PMLocalOverscrollFactory
API with OffsetOverscrollEffect
which is in the OverscrollEffect
doc, the offset doesn't work unless I use the old Modifier.overscroll
API.
Now I use the DrawModifierNode
instead of LayoutModifierNode
to make offset, it works, but the touch gesture is wrong. When touching a item in list with overscroll offset, apparently, another item (located orignally, without offset) will be touched.
How can I make the touch gesture account for the overscroll offset? Code details are in the thread.Kyant
02/06/2025, 12:07 PMoverride val node: DelegatableNode =
object : Modifier.Node(), LayoutModifierNode, DrawModifierNode {
override val shouldAutoInvalidate: Boolean = false
// don't work
override fun MeasureScope.measure(
measurable: Measurable,
constraints: Constraints
): MeasureResult {
val placeable = measurable.measure(constraints)
return layout(placeable.width, placeable.height) {
placeable.placeRelative(contentOffsetX.fastRoundToInt(), contentOffsetY.fastRoundToInt())
}
}
// work
override fun ContentDrawScope.draw() {
translate(contentOffsetX, contentOffsetY) {
this@draw.drawContent()
}
}
}
Louis Pullen-Freilich [G]
02/06/2025, 12:27 PMKyant
02/06/2025, 1:50 PM