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

added destroy method #22

Closed rhysburnie closed 7 years ago

rhysburnie commented 8 years ago

The destroy method resolves an issue I found when using Impetus to create a pseudo scrollable zone for a touch app. In my script the settings of Impetus need to update if content size changes, so it reinstantiates with new bound settings on the same source element.

However this resulted in multiple touchstart and mousedown events (for each time an instance was called) because onDown is an entirely new function for each instance, resulting in crazyness.

I realize that 90% of the time Impetus isn't used for scrolling and generally an instance would only be created once on a target element, however this small change allows a developer to remove the touchstart and mousedown if required at some point such as my use case.