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

Feat / swipe optimizations, features and fixes #54

Closed
wants to merge 9 commits into from

Conversation

ChristiaanScheermeijer
Copy link
Member

@ChristiaanScheermeijer ChristiaanScheermeijer commented Apr 24, 2024

This PR is based on #47 with some additional improvements and features.

The main problem with the transition between the swipe velocity and animation is that the speed needs to correspond with the swipe speed. In other words, if a user swipes with a velocity of 5 pixels per frame, it should animate from 5 pixels per frame to zero.

Before, we calculated the approximate end index and animated it to that index. This caused the starting speed to mismatch with the swipe speed, which didn't feel right.

I also added two new features:

  • Control the slider using a ref (currently exposing the slide, slideToIndex, and slideToPage methods)
  • Add closest?: boolean argument to the slideToIndex function. Instead of sliding to the absolute index, it slides to the closest circular item index

This PR also fixes a problem when there are no pages; the slider still animates, and the slide shows empty tiles or no tiles at all. Sliding is completely disabled no when there are no pages.

Update

I've just pushed an update with some improvements:

  • Interpolate the velocity and target position to get a less bumpy snapping (I want to push this further, but it feels already a lot better now)
  • Use the actual index when cancelling a touch gesture (snap to closest)
  • Use the actual index when swiping to account for current swipe distance

See https://66297348da698259008b816b--tile-slider-v2.netlify.app/

Copy link
Contributor

@royschut royschut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, again better!
As discussed, still room for some improvement on mobile (iOS mostly?). I'm trying to fine-tune as well.

Copy link

sonarcloud bot commented Apr 24, 2024

Quality Gate Passed Quality Gate passed

Issues
4 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@royschut
Copy link
Contributor

#55

Copy link
Contributor

@langemike langemike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 🎉 Thanks for the examples!

@ChristiaanScheermeijer
Copy link
Member Author

Superseded by #56

@ChristiaanScheermeijer ChristiaanScheermeijer deleted the feat/ios-swipe-optimization-v2 branch September 25, 2024 12:13
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

Successfully merging this pull request may close these issues.

3 participants