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

[jvm] HorizontalPager can't have snap scroll #3849

Closed
codlab opened this issue Oct 22, 2023 · 7 comments
Closed

[jvm] HorizontalPager can't have snap scroll #3849

codlab opened this issue Oct 22, 2023 · 7 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@codlab
Copy link

codlab commented Oct 22, 2023

edit : changed the title to be more explicit about the issue which makes more sense on desktops

Describe the bug
Scrolling using the trackpad won't pan on entire page : stopping mid "scroll" will keep the pages in a weird state where it doesn't magnet to the new "currentPage"

edit : removing this part : Using the HorizontalPager on jvm artifact will have this weird behaviour that no drag interaction can change pages. On Mac for instance, only either switching pages programmatically or scrolling on the trackpad will work. Shouldn't a mouse drag be working just like on mobile platforms ?

Affected platforms
Select one of the platforms below:

  • Desktop

Versions

  • Kotlin version*: 1.9.10
  • Compose Multiplatform version*: 1.5.10-beta02
  • OS version(s)* (required for Desktop and iOS issues): MacOS
  • OS architecture (x86 or arm64): arm64
  • JDK (for desktop issues): JDK shipped with Android Studio Hedgehog | 2023.1.1 Beta 5

To Reproduce
Steps and/or the code snippet to reproduce the behavior:

  1. Create a project which will have a screen with a HorizontalPager holding few dummy pages
  2. run
  3. Scroll horizontally the pager using the mouse or trackpads
  4. the pages won't snap scroll and just stop animating in between pages

Expected behavior
When scrolling using the trackpad, it should land to "full" currentPage instead of just be in a weird interstate
edit : removed It should be possible to scroll just on the other mobile platforms.

Additional context
I took a quick snippet from another issue just to check if it wasn't my implementation which was introducing such issues and could reproduce the issue right away

    val state = rememberPagerState(
        pageCount = { 3 }
    )

    ...
    HorizontalPager(
        modifier = Modifier.fillMaxSize(),
        state = state,
    ) { index ->
        when (index) {
            0 -> Box(modifier = Modifier.fillMaxSize().background(Color.Red))
            1 -> Box(modifier = Modifier.fillMaxSize().background(Color.Black))
            2 -> Box(modifier = Modifier.fillMaxSize().background(Color.Yellow))
        }
    }
@codlab codlab added bug Something isn't working submitted labels Oct 22, 2023
@alexzhirkevich
Copy link
Contributor

Have you tried Shift + Scroll? I believe this is a default way to perform horizontal scroll on desktop

@jbruchanov
Copy link

jbruchanov commented Oct 23, 2023

+1 on windows,
scrolling works only via

  • vertical wheel
  • horizontal shift + mouse wheel

but it can't be simply dragged by mouse click + drag...
also it seems to be working simply as scrollable container, there is no "snap scrolling effect"

@codlab
Copy link
Author

codlab commented Oct 23, 2023

scrolling works only via

Fair enough, it can be easily circumvented even tho the nowadays use cases all revolve around inverted behaviour where everything now matches touchscreens :p (interestingly, it reminds me I didn't check using a laptop with touchscreens)

also it seems to be working simply as scrollable container, there is no "snap scrolling effect"

this is problematic as the whole purpose of a "pager" is to actually introduce said snap scroll. Otherwise, this is simply a lazy horizontal list

@codlab codlab changed the title [jvm] HorizontalPager can't be scrolled using the mouse [jvm] HorizontalPager can't have snap scroll Oct 23, 2023
@alexzhirkevich
Copy link
Contributor

Now it's a duplicate of #3447

@codlab
Copy link
Author

codlab commented Oct 23, 2023

Awesome, I'll update this one then. Almost finished to work onto something which may be (hopefully) cleaner than using a LaunchedEffect

(keeping this one opened for now)

@dima-avdeev-jb
Copy link
Contributor

Thanks to @alexzhirkevich
It is duplicate of Issue #3447

@dima-avdeev-jb dima-avdeev-jb added duplicate This issue or pull request already exists and removed submitted labels Oct 27, 2023
@okushnikov
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

5 participants