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

[BUG] Quick sliding to the top and bottom, do not adjust this method "onPageChanged" #303

Open
JingChen1 opened this issue Oct 14, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@JingChen1
Copy link

Quick sliding, do not adjust this method "onPageChanged"

@JingChen1 JingChen1 added the bug Something isn't working label Oct 14, 2022
@JingChen1 JingChen1 changed the title [BUG] [BUG] Quick sliding, do not adjust this method "onPageChanged" Oct 14, 2022
@JingChen1 JingChen1 changed the title [BUG] Quick sliding, do not adjust this method "onPageChanged" [BUG] Quick sliding to the top and bottom, do not adjust this method "onPageChanged" Oct 14, 2022
@geraldvoit
Copy link
Contributor

I can confirm that there is an issue with the 'onPageChanged' handler.

Describe the bug

The 'onPageChanged' callback (PagerContent.swift:232) is not called in the event of gestures followed quickly by each other. Therefore, the app is not able to react on index change updates.

To Reproduce

  • Quick Drag Gesture from right to left followed instantly by a second one.

Expected behavior

'onPageChanged' handler will be called on every page index change.

Environment:

OS: iOS 16
SwiftUIPager 2.5.0

Additional context

The SwiftUIPager detects both Drag Gestures and finishes both with 'onDragGestureEnded' (PagerContent.swift:373). The 'onAnimationCompleted' (PagerContent.swift:227) observer triggers only once, which is totally fine. But the second 'onDragGestureEnded' call sets self.pagerModel.pageIncrement = 0. Therefore, the following 'onAnimationCompleted' observation won't trigger the 'onPageChanged' callback.

geraldvoit added a commit to geraldvoit/SwiftUIPager that referenced this issue Aug 8, 2023
Page.pageIncrement will be reset to 0 only after ‚onPageChanged‘ has been called.
@PatrickGaissert
Copy link

PatrickGaissert commented Aug 31, 2023

We really need this fix. For now we're pointing to the forked commit (thank you @geraldvoit !!!) but we would really like to have the fix in an official release of the library. Is there any chance this will happen?

fermoya pushed a commit that referenced this issue Sep 1, 2023
Page.pageIncrement will be reset to 0 only after ‚onPageChanged‘ has been called.
@alpha-moisol
Copy link

Hello, @fermoya. Can you create a new release of the library with this fix, please🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants