0

I'm using AutoSizer for one of the use cases in my application. in Autosizer code, they change the scrollTop due to which the scroll event is getting triggered. As the scroll events are captured (and not bubbled), how do I prevent scroll event in AutoSizer (or restrict the event only to the desired element)? The one way I could find is, checking if the target and currentTarget is same in the event handler

onScroll = event => {
    if(event.target === event.currentTarget){
        ...do Something
    }
} 

Is this the right way to do it or there is some other way? P.S. I'm using react in my application

Ajay Gaur
  • 5,140
  • 6
  • 38
  • 60

1 Answers1

0

If I understood you correctly you want to prevent scrolling on a parent component if child component has been scrolled. If yes, so use e.stopPropagation(); for it.

onScroll = event => {
    event.stopPropagation();
    // ...do Something
}