Stop propagating scroll events when modal dialogs are visible or scrollable popups have focus

This works, when the mouse enters the menu, by storing the scrollTop value and then setting the body to position: fixed with a top-margin equal to the scrollTop value. When the mouse leaves the menu, position: fixed is removed from the body and the body is scrolled to the stored scrollTop value. The downside is that when the mouse enters the menu it can cause the site logo in the header to reappear - I assume that is triggered by the scroll position.

// css
.stop-scrolling {
  position: fixed;
  margin-top: 0;
  width: 100%;
}
// menu-panel.js.es6
...
y_offsetWhenScrollingDisabled: 0,

mouseEnter() {
  this.y_offsetWhenScrollingDisabled = $(window).scrollTop();
  $('body').addClass('stop-scrolling').css('margin-top', -this.y_offsetWhenScrollingDisabled);
},

mouseLeave() {
  $('body').removeClass('stop-scrolling').css('margin-top', 0);
  $(window).scrollTop(this.y_offsetWhenScrollingDisabled);
},

إعجابَين (2)