Last active
October 25, 2017 10:13
-
-
Save pomle/dc028be96aa6aa1abf084cdf1c49935d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
class MyComponent extends React.Component { | |
constructor() { | |
super(); | |
this.handleMouseMove = scrollMiddleWare()(scroll => { | |
this.setState({ | |
movement: scroll.abs.x, | |
}); | |
}); | |
} | |
componentDidMount() { | |
window.addEventListener('mousemove', this.handleMouseMove); | |
} | |
componentWillUnmount() { | |
window.removeEventListener('mousemove', this.handleMouseMove); | |
} | |
render() { | |
return ( | |
<div onMouseMove={this.handleMouseMove} /> | |
) | |
} | |
} |
JustFly1984
commented
Oct 25, 2017
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment