question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onWheel Stop bubbling is not happening.

See original GitHub issue

My Target: I am having a div which scrolls. But on coming to the top or the bottom after the scrolling the div, the scrolling starts happening on the entire page itself which I don’t want. I think it’s happening due to event propagation, so I am trying to stop in following manner.

My Implementation: I am using “extends Component (es6 way)” to create my components. And I’ve put onWheel event listener as

return (
  <div className='scroll-box-list' onWheel = {(e)=>{console.log('Scrolling Me..'); e.stopPropagation();}}>
      <OtherThings />
  </div>
);

It’s consoling out ‘Scrolling Me’ fine but I am not able to stop propagating this event to the parent. Not sure why stopPropagation is not happening exactly or whether this issue is happening because of propagation

I don’t want to use libraries which used mixins, so please don’t suggest me this way.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

13reactions
thomasjmcommented, May 16, 2019

I hit this issue too, and eventually found this blog post explaining the root cause: https://medium.com/@ericclemmons/react-event-preventdefault-78c28c950e46

Using the nativeEvent didn’t work for me either, but it did work to use a ref on the element and manually do ref.current.addEventListener("wheel", (event) => event.stopPropagation())

1reaction
monkindeycommented, Mar 13, 2017

Hi , I used the event.preventDefault in React and it can work, The demo https://jsfiddle.net/monkindey/9kobyd2w/, I extract the logic code to be a npm package and it may be easy to use.

Hope it helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React JS: onWheel bubbling stopPropagation not working
I think it's happening due to event propagation, so I am trying to stop in following manner. My Implementation: I am using "extends...
Read more >
React 17 stops event bubbling in scroll event - Saeloun Blog
In React 17 the scroll event no longer bubbles to align with browser's behavior.
Read more >
How to stop the wheel event propagation - Esri Community
When I use wheel to zoom in/out, and the outer page has scroll bar - the wheel event bubbles to this outer page...
Read more >
Element: wheel event - Web APIs | MDN
The wheel event fires when the user rotates a wheel button on a pointing device (typically a mouse). This event replaces the non-standard ......
Read more >
SyntheticEvent - React
The synthetic events are different from, and do not map directly to, the browser's ... false from an event handler will no longer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found