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

On watchOS: drag ended animation starts from full previous screen #12

Closed
didierburton opened this issue Jan 28, 2021 · 3 comments
Closed

Comments

@didierburton
Copy link

didierburton commented Jan 28, 2021

Not sure if this is due to a new version of watchOS, but PageScrollState.swift's line 70:
self.pageOffset = 0.0
seems to reset the position of the "previous" page to its origin before doing the animation to the new page.
As a result, the swipe to an adjacent page has sort of a hiccup.
Moving the statement inside the DispatchQueue.main.async block fixes the issue. Lines 69~76 would change as follows:

       withAnimation(.easeInOut(duration: 0.2)) {
            self.selectedPage = newPage
        }
        
        DispatchQueue.main.async {
            self.pageOffset = 0.0
            self.isGestureActive = false
        }

Even so, swipe "end animations" still do seem a little unnatural, probably because the remaining distance--whatever it might be--is always reached in 0.2 second in an .easeInOut animation, which might benefit from being .easeOut only.
Thank you.

@didierburton
Copy link
Author

didierburton commented Jan 28, 2021

The fix actually needs to consider whether the new page is different:
The code for a natural gesture (with an .easeOut) becomes:

       withAnimation(.easeOut(duration: 0.2)) {
           if (newPage == selectedPage) {
               self.pageOffset = 0.0
           } else {
             self.selectedPage = newPage
           }
       }

And the DispatchQueue block would stay unaffected.

@fredyshox
Copy link
Owner

Sorry for the delay. It seems to work, I will add your fix into the next release :)

@fredyshox
Copy link
Owner

Fixed in 1.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants