impulsion
v1.1.3
Published
Add momentum to anything. It's like iScroll, except not for scrolling. Supports mouse and touch events.
Downloads
9
Readme
Impulsion.js
Fork of the excellent impetus.js by Chris Bateman.
Adds new features such as:
- Exposes
previousX
andpreviousY
to our lifecycle events.- Adds more lifecycle events:
onStart
: Called when starting to drag the element.onStartDecelerating
: Called when the deceleration begun.onEndDecelerating
: called when the deceleration has ended.As well other bugfixes and minor features.
Add momentum to anything. It's like iScroll, except not for scrolling. Supports mouse and touch events.
Check out the demos on the home page.
Impulsion will probably never support anything other than simple momentum. If you need scrolling or touch carousels or anything like that, this probably isn't the tool you're looking for.
Installation
yarn add impulsion
# or npm install impulsion
Usage
import Impulsion from 'impulsion';
// const Impulsion = require('impulsion');
let myImpulsion = new Impulsion({
source: myNode,
onUpdate(x, y, previousX, previousY) {
// whatever you want to do with the values
}
});
You give it an area to listen to for touch or mouse events, and it gives you the x
and y
values with some momentum.
Impulsion will register itself as an AMD module if it's available.
Constructor Options
Methods
Browser Support
Chrome, Firefox, Safari, Opera, IE 9+, iOS, Android. Support for IE 8 can be achieved by adding a polyfill for addEventListener
.