I used ReactJS to create a resume, that resume's body have 100vw and 100vh dimension ie, there is no scroll at window/body level, but inside resume there is one component which contains scroll. At the end I want to create a sticky Header. But before creating sticky header this code should run first. I tried this:
componentDidMount() {
ReactDOM.findDOMNode(this.refs.stickyHeader).addEventListener('scroll', this.isScrollOccured.bind(this));
}
componentWillUnmount() {
ReactDOM.findDOMNode(this.refs.stickyHeader).removeEventListener('scroll', this.isScrollOccured.bind(this));
}
isScrollOccured() {
console.log('Scrolling Occured');
}
render() {
return (
<div className="Container">
<div className="Header" ref="stickyHeader">
[...]
</div>
</div>
)
}
This is not giving any response, but if I change scroll event with wheel event inside addEventListener, it works fine, But I don't want to use wheel. I checked Other's Solution but it didn't work for me. Help me to find out the solution. If necessary I will upload Image.png of my work.