Skip to content

Commit

Permalink
Add event onWheel (#1)
Browse files Browse the repository at this point in the history
* add handle weel
  • Loading branch information
fdferrari authored and asmyshlyaev177 committed Jul 23, 2018
1 parent 64f98fd commit 3cc186f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"react-scripts": "1.1.4"
},
"scripts": {
"start": "PORT=3005 react-scripts start",
"start": "set PORT=3005 && react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-horizontal-scrolling-menu",
"version": "0.1.3",
"version": "0.1.4",
"description": "Scrolling horizontal menu component for React, support mouse and touch devices.",
"esnext": "src/index.js",
"browser": "build/index.js",
Expand Down
11 changes: 11 additions & 0 deletions src/scrollMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,16 @@ export class ScrollMenu extends React.Component {
return offset;
};

handleWheel = e => {
e.stopPropagation();
e.preventDefault();
if (e.deltaY < 0) {
this.handleArrowClick()
} else {
this.handleArrowClick(false)
}
}

handleArrowClick = (left = true) => {
const { alignCenter } = this.props;
const {
Expand Down Expand Up @@ -601,6 +611,7 @@ export class ScrollMenu extends React.Component {
<div
className={menuClass}
style={ menuStyle }
onWheel = {(e) => this.handleWheel(e)}
>

{arrowLeft &&
Expand Down

0 comments on commit 3cc186f

Please sign in to comment.