Skip to content

Commit

Permalink
Replace onWheel with addEventListener('wheel', {passive: false}) to r…
Browse files Browse the repository at this point in the history
…egain e.preventDefault functionality (#84)
  • Loading branch information
nadelalon authored Mar 3, 2020
1 parent 11ea1a0 commit 9141e96
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export default class ScrollHorizontal extends Component {
const orig = document.firstElementChild.className
document.firstElementChild.className = orig + (orig ? ' ' : '') + 'locked__'
}

DOM.findDOMNode(this.hScrollParent).addEventListener('wheel', this.onScrollStart, { passive: false })
}

componentWillUnmount() {
Expand All @@ -29,6 +31,8 @@ export default class ScrollHorizontal extends Component {
''
)
}

DOM.findDOMNode(this.hScrollParent).removeEventListener('wheel', this.onScrollStart)
}

componentDidUpdate = (prevProps) => {
Expand Down Expand Up @@ -149,7 +153,6 @@ export default class ScrollHorizontal extends Component {

return (
<div
onWheel={this.onScrollStart}
ref={r => {
this.hScrollParent = r
}}
Expand Down

0 comments on commit 9141e96

Please sign in to comment.