Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rememberSnapFlingBehavior does not snap on desktop when using a scroll wheel #3454

Closed
aljohnston112 opened this issue Aug 3, 2023 · 2 comments · Fixed by JetBrains/compose-multiplatform-core#1100
Assignees
Labels
bug Something isn't working discussion Need further discussion to understand if it actually needed help wanted Extra attention is needed reproduced

Comments

@aljohnston112
Copy link

aljohnston112 commented Aug 3, 2023

Describe the bug
rememberSnapFlingBehavior does not snap items to the center of the LazyColumn when scrolling via scroll wheel on desktop.

Affected platforms

  • Desktop

Versions

  • Kotlin version*: 1.9.0
  • Compose Multiplatform version*: 1.4.3
  • OS version(s)* (required for Desktop and iOS issues): Linux 6.4.6-100.fc37.x86_64
  • OS architecture (x86 or arm64): x86
  • JDK (for desktop issues): corretto-18.0.2

To Reproduce
Wrap this in a composable function

    val itemHeight = 48.dp
    val itemHeightModifier = modifier.height(itemHeight)
    LazyColumn(
        state = lazyListState,
        flingBehavior = rememberSnapFlingBehavior(lazyListState = lazyListState),
        modifier=itemHeightModifier.fillMaxWidth()
    ){
        items(
            5,
            key = { it }
        ){
            Text(it.toString(), modifier=itemHeightModifier)
        }
    }

Expected behavior
When scrolling through the LazyColumn and then stopping the scrolling, I expect the flingBehavior to snap the closest item to the center of the LazyColumn.

I can test this on Windows 10 later.

@aljohnston112 aljohnston112 added bug Something isn't working submitted labels Aug 3, 2023
@eymar
Copy link
Collaborator

eymar commented Aug 4, 2023

reproduced on Ubuntu (I guess the behaviour is OS independent).

it's likely related: #3447

Here is a screen recording. Desktop is on the left (scrolling using a mouse wheel), and android is on the right (using touch gestures: dragging).

simplescreenrecorder-2023-08-04_10.29.15.webm

@garretyoder
Copy link

In the other referenced similar issue #3447 I posted a workaround that works with a pager, it can probably be adapted for your use case as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working discussion Need further discussion to understand if it actually needed help wanted Extra attention is needed reproduced
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants