Multiple LazyRow Scrolling issue with in LazyColumn

32 views Asked by At

I have scenerio like,Lazycolumn have Top section with some horizontally scrolling items and bottom section with multiple features items(which are also scroll horizontally). Both section will sync horizontally scrolling(if any of features item is expanded). I have done some poc on with given suggestion two Lazy scrolling Facing problem like when scrolling any of horizonatal row then first click on button is not clickable but onging next click is perfectly working. Please suggest. enter image description here

     val pos = remember() {
        mutableIntStateOf(0)
    }
    val scope = rememberCoroutineScope()

    val productScroll = rememberLazyListState()
    val featureScroll = rememberLazyListState()

    
    
    LazyColumn() {
        stickyHeader {
            LazyRow(modifier = Modifier.wrapContentSize(), state = productScroll) {
                println("SCROLLLL 1")
                items(20) { index ->
                    Column(
                        modifier = Modifier
                            .size(100.dp)
                            .background(color = Color.Green)
                    ) {
                        Text("item ", color = Color.Red)
                        Text("$index")
                    }
                }
            }
        }
        itemsIndexed(dataList.value?: emptyList(),
           ) { index, item ->
            HeaderSection(item.header, item.isScroll, onHeaderClick = {
                pos.intValue=index
            })
            if (pos.intValue==index) {
                SectionBody(item, featureScroll)
            }
        }
        

    }
    LaunchedEffect(key1 = featureScroll.firstVisibleItemScrollOffset) {
        scope.launch {
            productScroll.scrollToItem(
                featureScroll.firstVisibleItemIndex,
                featureScroll.firstVisibleItemScrollOffset
            )
        }
    }
    LaunchedEffect(key1 = productScroll.firstVisibleItemScrollOffset) {
        scope.launch {
            featureScroll.scrollToItem(
                productScroll.firstVisibleItemIndex,
                productScroll.firstVisibleItemScrollOffset
            )
        }
    }

]3]3

1

There are 1 answers

0
Rajan1404930 On

Above problem statement is related to using two Launcheffect that creates loops between each other scrolling that why screen was nonclickable. I have add some condition to break loop like (!productScroll.isScrollInProgress)). This resolved the issue.