scroll-lock-body-2
Version:
scroll lock the body and remember the position
8 lines (7 loc) • 1.03 kB
JavaScript
/*!
* scroll-lock-body-2 v0.0.12
* (c) kunukn
* Released under the MIT License.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).scrollLockBody={})}(this,(function(e){"use strict";var t="data-scroll-lock-is-active",o="scrollLockNoPadding",d=function(){var e=document.documentElement.clientWidth;return Math.abs(window.innerWidth-e)};e.disableScrollLock=function(){null==document.body.dataset[o]&&(document.body.style.paddingRight=""),document.body.style.overflow="",document.body.removeAttribute(t)},e.enableScrollLock=function(){null==document.body.dataset[o]&&(d()&&(document.body.style.paddingRight=d()+"px"));document.body.style.overflow="hidden",document.body.setAttribute(t,"")},e.getScrollbarWidth=d,e.isScrollLockEnabled=function(){return null!=document.body.getAttribute(t)},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.umd.min.js.map