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

Not tracking 1:1 #157

Closed
iansilber opened this issue Nov 24, 2020 · 13 comments
Closed

Not tracking 1:1 #157

iansilber opened this issue Nov 24, 2020 · 13 comments
Labels
bug Something isn't working

Comments

@iansilber
Copy link

iansilber commented Nov 24, 2020

Describe the bug
When swiping the page doesn't track 1:1 (seems to lag a bit)

To Reproduce
Swipe across pages

Expected behavior
Typical paged views on iOS track 1:1 with your finger to make it feel smooth / responsive.

Environment:

  • iOS
  • iPhone 12

Additional context
Didn't see anything in the documentation to configure or adjust this.

@iansilber iansilber added the bug Something isn't working label Nov 24, 2020
@fermoya
Copy link
Owner

fermoya commented Nov 24, 2020

Hi @iansilber , can you please add a video or more information. I have no idea what “track 1:1” means

@iansilber
Copy link
Author

Yep — take a look at this video comparing the built in paging view and SwiftUIPager https://www.dropbox.com/s/ssvdnfh5wa5mk10/swiftuipager%20report.mp4?dl=0.

Notice how when using SwiftUIPager, it lags behind the mouse, as if it's being animated into position vs. being moved directly by the touch.

@fermoya
Copy link
Owner

fermoya commented Nov 24, 2020

Hi @iansilber , I see what you mean. SwiftUIPager uses a DragGesture. I’m not sure if you’ve used it before but the translation is not 100% exact. Plus, the gesture is “delayed” (minimumDistance is 15 pixels) so that it can work with ScrollView. Finally, only drags along the X axis are considered to modify the offset. This means that if you start moving horizontally but switch to a diagonal with an an angle wider than 30 degrees, then you’ll see the page will stop moving. All this combined is causing the effect you’re seeing.

I’m not sure how TabView and ScrollView are built internally but considering the resources available at the moment in SwiftUI at the moment, DragGesture is the best option despite its limitations.

@iansilber
Copy link
Author

Got it, thanks for the explanation.

@fermoya
Copy link
Owner

fermoya commented Nov 24, 2020

@iansilber don’t misunderstand, the request is very valid. Problem is at the moment there are no resources to do it :/

@vanities
Copy link

random, but if you change the animation duration to 0.01 instead of the default linear animation, it makes the scrolling much smoother

ref:

@fermoya
Copy link
Owner

fermoya commented Nov 25, 2020

Hi @vanities , thanks a lot for that, it does look very smooth indeed. Is this @iansilber something that looks appealing to you? It looks a simple change that makes a hell of an improvement! If so, I can arrange to have a release.

PS: I forgot to mention that the scroll is also normalized. So in your video, @iansilber , your page is narrower than you Pager container which means the offset is not exactly the same as your drag. With @vanities improvement, though, you'd get a quicker animation and the swiping wouldn't look lagged

PS2: if you ever find any piece of code that can be improved, please don't hesitate to send a PR or point it at me by opening an issue. I've worked on this for so long that sometimes I'm stubborn enough to not see the right solution.

@iansilber
Copy link
Author

I can take a look — what would I try exactly to give that a shot?

@fermoya
Copy link
Owner

fermoya commented Nov 25, 2020

So what @vanities suggested I believe is done and ready to try on version 1.14.0-beta.1. The animation is not so laggy as before. Just have in mind what I mentioned above. I've tried moving the mouse around randomly and eventually it detects a vertical shift and doesn't count it for the offset

@fermoya
Copy link
Owner

fermoya commented Nov 26, 2020

Hi, I've decided to remove that change as it's creating a weird effect when transitioning to the next page.

Will close this issue as there's nothing I'll be doing at the moment.

@fermoya
Copy link
Owner

fermoya commented Feb 22, 2021

This is solved on version 2.0.2

@vanities
Copy link

Thank you!

@iansilber
Copy link
Author

Thanks!

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

3 participants