JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.35k stars 1.18k forks source link

Snapping `SnapFlingBehavior` not working on desktop and web, works on Android #3602

Closed alexstyl closed 1 year ago

alexstyl commented 1 year ago

Describe the bug The below code is expected to produce a snapping effect according to the androidx docs. It works on Android. On Desktop and Canvas based Web it is as if the behavior is not applied:

import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.Text

val state = rememberLazyListState()

LazyRow(
    modifier = Modifier.fillMaxSize(),
    verticalAlignment = Alignment.CenterVertically,
    state = state,
    flingBehavior = rememberSnapFlingBehavior(lazyListState = state)
) {
    items(200) {
        Box(
            modifier = Modifier
                .height(400.dp)
                .width(200.dp)
                .padding(8.dp)
                .background(Color.Gray),
            contentAlignment = Alignment.Center
        ) {
            Text(it.toString(), fontSize = 32.sp)
        }
    }
}

Affected platforms Select one of the platforms below:

Versions

m-sasha commented 1 year ago

Thanks for the report. This is a duplicate of https://github.com/JetBrains/compose-multiplatform/issues/3454

okushnikov commented 3 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.