最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android jetpack compose - How to intercepter touch event in LazyList? - Stack Overflow

programmeradmin1浏览0评论

I have LazyRow which has a child which can pan and zoom. When the row is scrolled horizontally all events are intercepted by LazyList until the scrolling animation is finished. What I want to do - during scrolling animation tap the item and pan it vertically

                LazyRow(
                    modifier = Modifier
                        .fillMaxSize()
                        .pointerInput(Unit) {
                            coroutineScope {
                                awaitPointerEventScope {
                                    Timber.e("awaitEachGesture awaitPointerEventScope")

                                    var pan = Offset.Zero
                                    var pastTouchSlop = false
                                    val touchSlop = viewConfiguration.touchSlop
                                    while (true) {
                                        val event = awaitPointerEvent()
                                        val consumed = event.changes.fastAny { it.isConsumed }
                                        if (!consumed) {
                                            Timber.e("awaitEachGesture lazyList ${event.type}")

                                            if (event.type == PointerEventType.Release) {
                                                pan = Offset.Zero
                                                pastTouchSlop = false
                                                listTouchEnded = System.currentTimeMillis()

                                            } else if (event.type == PointerEventType.Move) {
                                                if (event.changes.size == 1) {
                                                    val panChange = event.calculatePan()
                                                    if (!pastTouchSlop) {
                                                        pan += panChange

                                                        val panMotion = pan.getDistance()

                                                        if (panMotion > touchSlop) {
                                                            pastTouchSlop = true
                                                        }
                                                    } else {
                                                        if (!pan.slopHorizontal()) {
                                                            listOffset = panChange.y
//                                                            event.changes.forEach {
//                                                                if (it.positionChanged()) {
//                                                                    it.consume()
//                                                                }
//                                                            }
                                                        }
                                                    }
                                                }
                                            }


                                        }
                                    }
                                }
                            }
                        },
发布评论

评论列表(0)

  1. 暂无评论