Useful for when a blocking user experience is needed (in my case, didn't want people unwittingly loosing their place by scrolling while a modal required their attention): $.scrollLock()
locks the body in place, preventing scroll until it is unlocked.
// Locks the page if it's currently unlocked
$.scrollLock();
// ...or vice versa
$.scrollLock();
// Locks the page
$.scrollLock( true );
// Unlocks the page
$.scrollLock( false );
Thanks for this. Unfortunately the simple version does not work well on iOS. The page still scrolls underneath my overlay,
overflow: hidden
doesn't perform the same on Apple devices. I can't find documentation of this (go figure), but here is the fix I was using. However, when I use that CSS, the page scrolls to the top. Yet, the original version seems to work fine and locks the body scroll position in place.