chrisbateman / impetus

Agnostic utility for adding momentum to anything. It's like iScroll, except not for scrolling. Supports mouse and touch events.
chrisbateman.github.io/impetus
MIT License
487 stars 70 forks source link

Bounds rubber-banding #8

Closed abusedmedia closed 9 years ago

abusedmedia commented 9 years ago

Hi there Thanks for this very useful library. I'm wondering if it would be possible to add a kind of negative inertia when bounds are defined thus the x/y props would be smoothly slowed down and bounced back to the bound value instead stopped immediately.

yckart commented 9 years ago

:+1:

chrisbateman commented 9 years ago

Definitely wouldn't mind adding this - I'll try to get around to it...

RuudBurger commented 9 years ago

I'd like this as well ;) so just a +1

chrisbateman commented 9 years ago

I added this in a separate branch - https://github.com/chrisbateman/impetus/tree/bounce

Please try it out if you can and let me know how it goes. Probably still needs some tweaking.

abusedmedia commented 9 years ago

Very nice Chris! Just tested briefly and it looks very good. I would only add a cumulative friction during drag in order to slow down until stop after a while... You can check my quick&dirty implementation about what I mean, here: https://github.com/abusedmedia/impetus/blob/bounce/impetus.js#L208-L211

Thank you!

chrisbateman commented 9 years ago

@abusedmedia Added that in the bounce branch. Still might want to tweak some of the overall physics a bit...

chrisbateman commented 9 years ago

Anybody have a preference on whether this should be enabled by default? My thought is yes...

chrisbateman commented 9 years ago

Implemented as of v0.8.0

pyrsmk commented 9 years ago

:+1: