Closed robinst closed 2 years ago
I'm having the exact same issue, but with swiping from the top edge to view the notification center.
Hi @robinst thanks for the suggestion. I'll take a look, I'm aware of the issue of that exists when you combine gestures in (or views that implicitly have a gesture) in SwiftUI. In UIKit there are option to request a gesture to fail before being recognized but the same doesn't apply here.
I'll take a look at your suggestion. I can always create a beta version and get feedback from it.
@denizdogan have you tried the suggestion above?
Out of curiosity, have you tried delaysTouches
and pagingPriority
?
@fermoya My use of the component is currently very "barebones", but I'm thinking maybe it would be simpler to just adjust the "gesturable area", so that it doesn't react when the touch starts outside of the safe area?
That should be already possible, the library ships with swipeInteractionArea
modifier. It's possible to limit the interaction to just the page and not the whole container.
Problem here is there's no such thing as a safe area here. Pager
expands and takes up as much space as its container. If the the parent expands till the status bar, then so does Pager
. In your case it would be a matter of ensuring this. I'm guessing wrapping Pager
into a VStack
.
Similarly, using swipeInteractionArea
might help in case .page
is selected, although I don't think it would make much of a difference if the page reaches the edges of the screen.
I'll take a look at coordinateSpace
, it seems like a good start
Out of curiosity, have you tried
delaysTouches
andpagingPriority
?
Yeah just tried that, it doesn't change anything.
I'll take a look at
coordinateSpace
, it seems like a good start
Note that that breaks the "More" example where swiping is vertical or right to left (because of rotation3DEffect
). But that could be fixed by changing the code in onDragChanged
to be aware of the direction instead.
this should be fixed here in case you want to check it out: https://github.com/fermoya/SwiftUIPager/releases/tag/2.3.3-beta.3
Yess, that fixes it, thank you :)! Hopefully it fixes @denizdogan's problem too.
Thanks for the quick fix @fermoya, I've bought you a few coffees as a thank you :)
@fermoya So you just to circle back, swipeInteractionArea
did nothing for me, as you expected. My issue is that the pager covers the entire screen, and when I swipe down from the very top of the screen to open the notification center, the pager also swipes up. Should I open another issue about this?
@denizdogan try the mates version 2.3.3
if that helps but what you must ensure then is that Pager
stats within the Safe Area. That's up to you, not the library, check out the examples in the repo.
@fermoya Sorry, I should have mentioned I was already using 2.3.3. That's unfortunate to hear, IMO the library would do good to allow us to define offsets from the edges where the pager should ignore gestures.
@denizdogan please open a new issue and share your code or a small snippet to reproduce, maybe a video too. But please, first check out the examples in the repo. I’m using a Pager
inside a NavigationView
and it doesn’t use the safe area. What I’m saying is Pager
doesn’t use the safe area unless you specify it so my guess is there’s something in your code that makes it use it.
please open a new thread
Describe the bug When using a Pager within subview of a
NavigationView
and then navigating back using a swipe gesture from the left screen edge, the gesture causes the pager to go to the next page while the swipe gesture is being performed, see video below.To Reproduce
NavigationView
that contains aNavigationLink
with a destination view that contains aPager
Expected: Navigates back to the previous view, the pager doesn't change. Actual: The pager swipes to the next page while the gesture is being performed. It's doesn't always happen but pretty often, maybe depending on how quick the gesture is performed.
Code to reproduce (drop into the Examples in SwiftUIPagerExample):
Screenshots / Videos
https://user-images.githubusercontent.com/16778/158742041-9943a2d6-adb1-4019-a22d-aa10c06e867b.mp4
Notice how, while performing the edge swipe gesture to navigate back, the pager goes to the next page (from blue to red).
Environment:
Additional context Some observations:
onDragChanged
inPagerContent
. When adding a print fornewOffset
at the end of the method, I'm getting values like 0.0, 4.0, -386.0. The last one seems strange. I'm not sure how exactly the ongoing gesture forNavigationView
affects the pager's gesture coordinates, but somewhere there seems to be the problem.swipeGesture
toDragGesture(minimumDistance: minimumDistance, coordinateSpace: .global)
, it fixes the problem in this particular case, but that would probably have other unintended side effects.