Skip to content

Instantly share code, notes, and snippets.

View divola's full-sized avatar

Alex Divola divola

View GitHub Profile
@divola
divola / README.md
Created March 21, 2020 19:55 — forked from barneycarroll/README.md
Lock and unlock a page's scroll position.

jquery.scrollLock.js

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