Skip to content

Instantly share code, notes, and snippets.

View suraj-palerra's full-sized avatar

Suraj Khakurel suraj-palerra

View GitHub Profile
@suraj-palerra
suraj-palerra / README.md
Created June 21, 2016 17:58 — 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