Skip to content

Commit

Permalink
Merge pull request #46 from luckypike/master
Browse files Browse the repository at this point in the history
Add onWheel callback for swap axes
  • Loading branch information
ilyashubin authored May 24, 2020
2 parents 1bdd951 + 23290b4 commit 94c602c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default class ScrollBooster {
* @param {Boolean} options.emulateScroll - enables mousewheel emulation
* @param {Function} options.onClick - click handler
* @param {Function} options.onUpdate - state update handler
* @param {Function} options.onWheel - wheel handler
* @param {Function} options.shouldScroll - predicate to allow or disable scroll
*/
constructor(options = {}) {
Expand All @@ -66,6 +67,7 @@ export default class ScrollBooster {
pointerDownPreventDefault: true,
onClick() {},
onUpdate() {},
onWheel() {},
shouldScroll() {
return true;
},
Expand Down Expand Up @@ -470,6 +472,7 @@ export default class ScrollBooster {
};

this.events.wheel = (event) => {
const state = this.getState();
if (!this.props.emulateScroll) {
return;
}
Expand All @@ -480,6 +483,8 @@ export default class ScrollBooster {
this.scrollOffset.x = -event.deltaX;
this.scrollOffset.y = -event.deltaY;

this.props.onWheel(state, event);

this.startAnimationLoop();

clearTimeout(wheelTimer);
Expand Down

0 comments on commit 94c602c

Please sign in to comment.