SwiftUIPager icon indicating copy to clipboard operation
SwiftUIPager copied to clipboard

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

Open JingChen1 opened this issue 2 years ago • 4 comments

Quick sliding, do not adjust this method "onPageChanged"

JingChen1 avatar Oct 14 '22 03:10 JingChen1

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 avatar Aug 08 '23 12:08 geraldvoit

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?

PatrickGaissert avatar Aug 31 '23 14:08 PatrickGaissert

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

alpha-moisol avatar Mar 07 '24 11:03 alpha-moisol