luster-io / impulse

Dynamic Physics Interactions for the Mobile Web
http://impulse.luster.io
MIT License
1.59k stars 74 forks source link

decelerate chaining #19

Open mpohl opened 10 years ago

mpohl commented 10 years ago

I need to know when a deceleration is finished, but using .then() only works if the position .end() is reached which might not happen. Is there a possible way to go?

xcoderzach commented 10 years ago

yeah, the promise should resolve when it stops, regardless of whether it reaches it's destination. This is a bug. I'll fix it later today when I get back to my computer.

https://github.com/luster-io/impulse/blob/master/lib/decelerate.js#L28

should be

update.done(position, velocity)
xcoderzach commented 10 years ago

If you need something FAST, as in right now, you can do promise.catch ( or promise['catch'] for older browsers ) which will get called when it "didn't reach end".

mpohl commented 10 years ago

Great, thanks!