react-native-pager icon indicating copy to clipboard operation
react-native-pager copied to clipboard

feat: add velocity to spring animation

Open leethree opened this issue 5 years ago • 12 comments

This PR adds support for momentum scrolling by taking into account the velocity when drag is released into the spring animation.

leethree avatar Oct 24 '19 10:10 leethree

this is great -- thanks so much! i'll run a few tests and merge this if all is well 👍

ajsmth avatar Oct 29 '19 13:10 ajsmth

my only issue with this is that its super sensitive to numberOfPages -- a quick swipe can move the index +/- ~15 pages. i wonder if theres a default coefficient for handling this kind of thing...or perhaps clamping the number of pages moved?

ajsmth avatar Oct 29 '19 14:10 ajsmth

@ajsmth I added a parameter velocityMultiplier to control how much you want it to scroll. let me know if it works!

leethree avatar Nov 04 '19 11:11 leethree

updated the PR to work with v0.2

leethree avatar Dec 18 '19 17:12 leethree

U don't want to add this @ajsmth? It's such a great library and needs some more love :)

hirbod avatar May 22 '20 00:05 hirbod

hey - i would love to add this but it’s always broken existing functionality when i’ve tested it. i will take some time to try and add it if it’s something people want.

rn-reanimated is coming out with some major improvements soon, perhaps i will wait for the next release and do a proper overhaul of this lib

ajsmth avatar May 22 '20 00:05 ajsmth

Sounds great. I was trying to optimize the lib on android (because its not working super great on it) using react-native-screens. Not sure if its possible and if there is a big improvement but maybe moving it to native containers might help to boost it (just as a thought)

hirbod avatar May 22 '20 00:05 hirbod

thanks, i’ll keep it in mind. i’m quite familiar with rn-screens as well. i suspect some of the android issues will be addressed as they are supposedly moving more of the lib to the native thread. we’ll see

ajsmth avatar May 22 '20 00:05 ajsmth

Crossing fingers reanimated drops soon enough before Expo SDK 38 lands :D

hirbod avatar May 22 '20 00:05 hirbod

looks like it was released today: https://blog.swmansion.com/introducing-reanimated-2-752b913af8b3

i'll be looking at improving this lib

ajsmth avatar May 28 '20 16:05 ajsmth

Crazy news! Please don't drop too many BCs :D

hirbod avatar May 28 '20 17:05 hirbod

Limitations are pretty high atm: https://docs.swmansion.com/react-native-reanimated/docs/about

I think its to early to adopt to Reanimated2 - its also Hermes only for android. (which expo does not support currently) Your improvements might lead to a new major version imho.

hirbod avatar May 28 '20 18:05 hirbod