0

I would like to disable scrolling once a button is pressed. I already found this answer and it's really good - but the user is still able to scroll by marking something on the page and drag it to the top/bottom of the browser.

This code resets the scroll position as quick as possible, but the scrolling is still visible (and this solutions appears a bit dirty)

var pageYOffset = window.pageYOffset;
setInterval(function () { window.scrollTo(0, pageYOffset) }, 1);
Community
  • 1
  • 1
Christopher
  • 1,891
  • 3
  • 22
  • 46

1 Answers1

1

You can try by disabling text selection highlighting when scrolling is in disabled state.

try this fiddle

in disable_scroll() add

$("html").addClass("diableSelection");

and in enable_scroll() add

$("html").removeClass("diableSelection");

where .diableSelection will be

.diableSelection {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
Community
  • 1
  • 1
Acha Bhoot
  • 68
  • 5
  • Thank you! Unfortunately, my questions seems to be over simplified: I have an element on my site which has to be draggable :/ But that's my fault, you answered my question anyway – Christopher Apr 03 '13 at 11:38
  • maybe it's the fiddle, but it doesn't work: the page scrolls up/down when i drag my mouse outside of its region... – mike Jun 02 '16 at 16:15