Add callback when user tries to swipe past the first or last item
Closed this issue · 6 comments
I was wondering if you could write a callback when the user tries to swipe past the first or last item. I was wanting to perform an action when a user attempts to swipe past the last item in the pager and figured this could be a quick and easy update.
This is an interesting idea - thanks for the suggestion.
Can you help me understand your use case/provide an example of how this would be used?
I agree that this could be added, but getting it right could be a bit tricky since I expect we would need some kind of swipe threshold (similar to the dismiss gesture) to differentiate between an intentional swipe and an accidental swipe.
So I'm looking at creating a profile view, which the user can add up to 5 photos in the profile. The screenshot I created a page indicator which just shows 3 photos. The profile will also have detail scroll view at the bottom which a button will expand the ScrollView to cover the full screen. I was thinking if the user is on the last photo and tries to scroll past it, I would have the code listen for that and then expand the ScrollView to full screen so the user won't have to click the expand button.
Cool makes sense.
let me see what I can do.
I'm a bit busy at the moment so I may not get this out super quick but ill hack on it.
(Also happy to accept a PR 😄)
Ive pushed a change to main
that should add this support.
Would you be able to test it out and let me know if it works for you? If so I'll cut a release
Usage:
.overscroll { position in
if position == .beginning {
print("Swiped past beginning")
} else {
print("Swiped past end")
}
}
It appears to be working great. Thank you
Awesome! Ill make a release. Thanks for the input!