utikeev
02/23/2021, 7:36 PMDragObserver
got deprecated, but I didn't manage to properly migrate my implementation to new API.
Using two draggable
modifiers prevents from dragging simultaneously in both directions and zooming at the same time, while using pointerInput
lacks was kind of tricky:
• detectDragGestures
lack onStart
and velocity
parameter in onEnd
callback
• drag
function seems to allow more fine-grained setting up, but judging by detectDragGestures
is also quite hard to handle. Also velocity
has to be calculated somehow (isn't really clear)
I'll attach deprecated snippet, which I currently use, and would be glad to know several directions on how it can be implemented with new API with the similar amount of code.modifier = modifier
.zoomable { coroutineScope.launch { state.zoom(it) } }
.rawDragGestureFilter(object : DragObserver {
override fun onDrag(dragDistance: Offset): Offset {
with(state) {
coroutineScope.launch { setTranslationX(translationX + dragDistance.x / pageWidth) }
translationY += dragDistance.y / pageHeight
}
return super.onDrag(dragDistance)
}
override fun onStart(downPosition: Offset) {
state.selectionState = PagerState.SelectionState.Undecided
super.onStart(downPosition)
}
override fun onStop(velocity: Offset) {
coroutineScope.launch { state.fling(velocity.x / pageWidth) }
super.onStop(velocity)
}
})
Andrey Kulikov
02/23/2021, 11:33 PMutikeev
02/24/2021, 7:55 AMScrollable
. Will scrollable
and transformable
work simultaneously, so I can use transformable
for Y axis and zoom and scrollable
for X axis?Andrey Kulikov
02/24/2021, 12:11 PMmatvei
02/24/2021, 12:30 PMModifier.pointerInput
directly with drag
extesion function on it and the zoom handling as well. WE have all the helper functions available in foundation for convenience, but yeah, you will have to create and add events to the velocity tracker manually, which is still simple, but the drag/ centroid handling you can calculate via our own functions.cb
02/24/2021, 4:44 PMutikeev
02/24/2021, 6:16 PMHalil Ozercan
05/03/2021, 8:59 AMcentroid
in transformable state. Transformable modifier and scroll works well together but now I don't have access to the centroid. If I use detectTransformGestures
to access the centroid, then it doesn't work well with verticalScroll
.