A utility for auto-scroll when trigger location of event (i.e. mouse event) almost reach boundary.
- Install the latest version of autoscroll:
npm install --save autoscroll
- At this point you can import
autoscroll:
importautoScrollfrom'autoscroll';importReact,{PureComponent}from'react';importautoScrollfrom'autoscroll';classExampleextendsPureComponent{refContent=(content)=>{this.content=content;}actions={onMouseMove: (e)=>{// Start auto scrollingautoScroll.run(e,this.content);},onMouseOut: (e)=>{// Stop auto scrolling if anyautoScroll.end();}};render(){return(<divstyle={{height: 500,overflow: 'auto'}}ref={this.refContent}onMouseMove={this.actions.onMouseMove}onMouseOut={this.actions.onMouseOut}><divstyle={{height: 1000,backgroundColor: 'yellow'}}/></div>);}}exportdefaultExample;