body-scroll-lock
Advanced tools
Comparing version 3.1.3 to 3.1.4
@@ -72,7 +72,3 @@ | ||
previousBodyOverflowSetting = document.body.style.overflow; | ||
// Setting overflow on body/documentElement synchronously in Desktop Safari slows down | ||
// the responsiveness for some reason. Setting within a setTimeout fixes this. | ||
setTimeout(() => { | ||
document.body.style.overflow = 'hidden'; | ||
}); | ||
document.body.style.overflow = 'hidden'; | ||
} | ||
@@ -82,21 +78,17 @@ }; | ||
const restoreOverflowSetting = () => { | ||
// Setting overflow on body/documentElement synchronously in Desktop Safari slows down | ||
// the responsiveness for some reason. Setting within a setTimeout fixes this. | ||
setTimeout(() => { | ||
if (previousBodyPaddingRight !== undefined) { | ||
document.body.style.paddingRight = previousBodyPaddingRight; | ||
if (previousBodyPaddingRight !== undefined) { | ||
document.body.style.paddingRight = previousBodyPaddingRight; | ||
// Restore previousBodyPaddingRight to undefined so setOverflowHidden knows it | ||
// can be set again. | ||
previousBodyPaddingRight = undefined; | ||
} | ||
// Restore previousBodyPaddingRight to undefined so setOverflowHidden knows it | ||
// can be set again. | ||
previousBodyPaddingRight = undefined; | ||
} | ||
if (previousBodyOverflowSetting !== undefined) { | ||
document.body.style.overflow = previousBodyOverflowSetting; | ||
if (previousBodyOverflowSetting !== undefined) { | ||
document.body.style.overflow = previousBodyOverflowSetting; | ||
// Restore previousBodyOverflowSetting to undefined | ||
// so setOverflowHidden knows it can be set again. | ||
previousBodyOverflowSetting = undefined; | ||
} | ||
}); | ||
// Restore previousBodyOverflowSetting to undefined | ||
// so setOverflowHidden knows it can be set again. | ||
previousBodyOverflowSetting = undefined; | ||
} | ||
}; | ||
@@ -129,45 +121,41 @@ | ||
export const disableBodyScroll = (targetElement, options) => { | ||
if (isIosDevice) { | ||
// targetElement must be provided, and disableBodyScroll must not have been | ||
// called on this targetElement before. | ||
if (!targetElement) { | ||
// eslint-disable-next-line no-console | ||
console.error('disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.'); | ||
return; | ||
} | ||
// targetElement must be provided | ||
if (!targetElement) { | ||
// eslint-disable-next-line no-console | ||
console.error('disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.'); | ||
return; | ||
} | ||
if (targetElement && !locks.some(lock => lock.targetElement === targetElement)) { | ||
const lock = { | ||
targetElement, | ||
options: options || {} | ||
}; | ||
// disableBodyScroll must not have been called on this targetElement before | ||
if (locks.some(lock => lock.targetElement === targetElement)) { | ||
return; | ||
} | ||
locks = [...locks, lock]; | ||
const lock = { | ||
targetElement, | ||
options: options || {} | ||
}; | ||
targetElement.ontouchstart = event => { | ||
if (event.targetTouches.length === 1) { | ||
// detect single touch. | ||
initialClientY = event.targetTouches[0].clientY; | ||
} | ||
}; | ||
targetElement.ontouchmove = event => { | ||
if (event.targetTouches.length === 1) { | ||
// detect single touch. | ||
handleScroll(event, targetElement); | ||
} | ||
}; | ||
locks = [...locks, lock]; | ||
if (!documentListenerAdded) { | ||
document.addEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined); | ||
documentListenerAdded = true; | ||
if (isIosDevice) { | ||
targetElement.ontouchstart = event => { | ||
if (event.targetTouches.length === 1) { | ||
// detect single touch. | ||
initialClientY = event.targetTouches[0].clientY; | ||
} | ||
}; | ||
targetElement.ontouchmove = event => { | ||
if (event.targetTouches.length === 1) { | ||
// detect single touch. | ||
handleScroll(event, targetElement); | ||
} | ||
}; | ||
if (!documentListenerAdded) { | ||
document.addEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined); | ||
documentListenerAdded = true; | ||
} | ||
} else { | ||
setOverflowHidden(options); | ||
const lock = { | ||
targetElement, | ||
options: options || {} | ||
}; | ||
locks = [...locks, lock]; | ||
} | ||
@@ -189,4 +177,2 @@ }; | ||
locks = []; | ||
// Reset initial clientY. | ||
@@ -196,31 +182,28 @@ initialClientY = -1; | ||
restoreOverflowSetting(); | ||
locks = []; | ||
} | ||
locks = []; | ||
}; | ||
export const enableBodyScroll = targetElement => { | ||
if (!targetElement) { | ||
// eslint-disable-next-line no-console | ||
console.error('enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.'); | ||
return; | ||
} | ||
locks = locks.filter(lock => lock.targetElement !== targetElement); | ||
if (isIosDevice) { | ||
if (!targetElement) { | ||
// eslint-disable-next-line no-console | ||
console.error('enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.'); | ||
return; | ||
} | ||
targetElement.ontouchstart = null; | ||
targetElement.ontouchmove = null; | ||
locks = locks.filter(lock => lock.targetElement !== targetElement); | ||
if (documentListenerAdded && locks.length === 0) { | ||
document.removeEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined); | ||
documentListenerAdded = false; | ||
} | ||
} else { | ||
locks = locks.filter(lock => lock.targetElement !== targetElement); | ||
if (!locks.length) { | ||
restoreOverflowSetting(); | ||
} | ||
} else if (!locks.length) { | ||
restoreOverflowSetting(); | ||
} | ||
}; | ||
@@ -74,7 +74,3 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
previousBodyOverflowSetting = document.body.style.overflow; | ||
// Setting overflow on body/documentElement synchronously in Desktop Safari slows down | ||
// the responsiveness for some reason. Setting within a setTimeout fixes this. | ||
setTimeout(function () { | ||
document.body.style.overflow = 'hidden'; | ||
}); | ||
document.body.style.overflow = 'hidden'; | ||
} | ||
@@ -84,21 +80,17 @@ }; | ||
var restoreOverflowSetting = function restoreOverflowSetting() { | ||
// Setting overflow on body/documentElement synchronously in Desktop Safari slows down | ||
// the responsiveness for some reason. Setting within a setTimeout fixes this. | ||
setTimeout(function () { | ||
if (previousBodyPaddingRight !== undefined) { | ||
document.body.style.paddingRight = previousBodyPaddingRight; | ||
if (previousBodyPaddingRight !== undefined) { | ||
document.body.style.paddingRight = previousBodyPaddingRight; | ||
// Restore previousBodyPaddingRight to undefined so setOverflowHidden knows it | ||
// can be set again. | ||
previousBodyPaddingRight = undefined; | ||
} | ||
// Restore previousBodyPaddingRight to undefined so setOverflowHidden knows it | ||
// can be set again. | ||
previousBodyPaddingRight = undefined; | ||
} | ||
if (previousBodyOverflowSetting !== undefined) { | ||
document.body.style.overflow = previousBodyOverflowSetting; | ||
if (previousBodyOverflowSetting !== undefined) { | ||
document.body.style.overflow = previousBodyOverflowSetting; | ||
// Restore previousBodyOverflowSetting to undefined | ||
// so setOverflowHidden knows it can be set again. | ||
previousBodyOverflowSetting = undefined; | ||
} | ||
}); | ||
// Restore previousBodyOverflowSetting to undefined | ||
// so setOverflowHidden knows it can be set again. | ||
previousBodyOverflowSetting = undefined; | ||
} | ||
}; | ||
@@ -133,47 +125,43 @@ | ||
export var disableBodyScroll = function disableBodyScroll(targetElement, options) { | ||
if (isIosDevice) { | ||
// targetElement must be provided, and disableBodyScroll must not have been | ||
// called on this targetElement before. | ||
if (!targetElement) { | ||
// eslint-disable-next-line no-console | ||
console.error('disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.'); | ||
return; | ||
} | ||
// targetElement must be provided | ||
if (!targetElement) { | ||
// eslint-disable-next-line no-console | ||
console.error('disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.'); | ||
return; | ||
} | ||
if (targetElement && !locks.some(function (lock) { | ||
return lock.targetElement === targetElement; | ||
})) { | ||
var lock = { | ||
targetElement: targetElement, | ||
options: options || {} | ||
}; | ||
// disableBodyScroll must not have been called on this targetElement before | ||
if (locks.some(function (lock) { | ||
return lock.targetElement === targetElement; | ||
})) { | ||
return; | ||
} | ||
locks = [].concat(_toConsumableArray(locks), [lock]); | ||
var lock = { | ||
targetElement: targetElement, | ||
options: options || {} | ||
}; | ||
targetElement.ontouchstart = function (event) { | ||
if (event.targetTouches.length === 1) { | ||
// detect single touch. | ||
initialClientY = event.targetTouches[0].clientY; | ||
} | ||
}; | ||
targetElement.ontouchmove = function (event) { | ||
if (event.targetTouches.length === 1) { | ||
// detect single touch. | ||
handleScroll(event, targetElement); | ||
} | ||
}; | ||
locks = [].concat(_toConsumableArray(locks), [lock]); | ||
if (!documentListenerAdded) { | ||
document.addEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined); | ||
documentListenerAdded = true; | ||
if (isIosDevice) { | ||
targetElement.ontouchstart = function (event) { | ||
if (event.targetTouches.length === 1) { | ||
// detect single touch. | ||
initialClientY = event.targetTouches[0].clientY; | ||
} | ||
}; | ||
targetElement.ontouchmove = function (event) { | ||
if (event.targetTouches.length === 1) { | ||
// detect single touch. | ||
handleScroll(event, targetElement); | ||
} | ||
}; | ||
if (!documentListenerAdded) { | ||
document.addEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined); | ||
documentListenerAdded = true; | ||
} | ||
} else { | ||
setOverflowHidden(options); | ||
var _lock = { | ||
targetElement: targetElement, | ||
options: options || {} | ||
}; | ||
locks = [].concat(_toConsumableArray(locks), [_lock]); | ||
} | ||
@@ -195,4 +183,2 @@ }; | ||
locks = []; | ||
// Reset initial clientY. | ||
@@ -202,35 +188,30 @@ initialClientY = -1; | ||
restoreOverflowSetting(); | ||
locks = []; | ||
} | ||
locks = []; | ||
}; | ||
export var enableBodyScroll = function enableBodyScroll(targetElement) { | ||
if (!targetElement) { | ||
// eslint-disable-next-line no-console | ||
console.error('enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.'); | ||
return; | ||
} | ||
locks = locks.filter(function (lock) { | ||
return lock.targetElement !== targetElement; | ||
}); | ||
if (isIosDevice) { | ||
if (!targetElement) { | ||
// eslint-disable-next-line no-console | ||
console.error('enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.'); | ||
return; | ||
} | ||
targetElement.ontouchstart = null; | ||
targetElement.ontouchmove = null; | ||
locks = locks.filter(function (lock) { | ||
return lock.targetElement !== targetElement; | ||
}); | ||
if (documentListenerAdded && locks.length === 0) { | ||
document.removeEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined); | ||
documentListenerAdded = false; | ||
} | ||
} else { | ||
locks = locks.filter(function (lock) { | ||
return lock.targetElement !== targetElement; | ||
}); | ||
if (!locks.length) { | ||
restoreOverflowSetting(); | ||
} | ||
} else if (!locks.length) { | ||
restoreOverflowSetting(); | ||
} | ||
}; | ||
@@ -103,7 +103,3 @@ (function (global, factory) { | ||
previousBodyOverflowSetting = document.body.style.overflow; | ||
// Setting overflow on body/documentElement synchronously in Desktop Safari slows down | ||
// the responsiveness for some reason. Setting within a setTimeout fixes this. | ||
setTimeout(function () { | ||
document.body.style.overflow = 'hidden'; | ||
}); | ||
document.body.style.overflow = 'hidden'; | ||
} | ||
@@ -113,21 +109,17 @@ }; | ||
var restoreOverflowSetting = function restoreOverflowSetting() { | ||
// Setting overflow on body/documentElement synchronously in Desktop Safari slows down | ||
// the responsiveness for some reason. Setting within a setTimeout fixes this. | ||
setTimeout(function () { | ||
if (previousBodyPaddingRight !== undefined) { | ||
document.body.style.paddingRight = previousBodyPaddingRight; | ||
if (previousBodyPaddingRight !== undefined) { | ||
document.body.style.paddingRight = previousBodyPaddingRight; | ||
// Restore previousBodyPaddingRight to undefined so setOverflowHidden knows it | ||
// can be set again. | ||
previousBodyPaddingRight = undefined; | ||
} | ||
// Restore previousBodyPaddingRight to undefined so setOverflowHidden knows it | ||
// can be set again. | ||
previousBodyPaddingRight = undefined; | ||
} | ||
if (previousBodyOverflowSetting !== undefined) { | ||
document.body.style.overflow = previousBodyOverflowSetting; | ||
if (previousBodyOverflowSetting !== undefined) { | ||
document.body.style.overflow = previousBodyOverflowSetting; | ||
// Restore previousBodyOverflowSetting to undefined | ||
// so setOverflowHidden knows it can be set again. | ||
previousBodyOverflowSetting = undefined; | ||
} | ||
}); | ||
// Restore previousBodyOverflowSetting to undefined | ||
// so setOverflowHidden knows it can be set again. | ||
previousBodyOverflowSetting = undefined; | ||
} | ||
}; | ||
@@ -162,47 +154,43 @@ | ||
var disableBodyScroll = exports.disableBodyScroll = function disableBodyScroll(targetElement, options) { | ||
if (isIosDevice) { | ||
// targetElement must be provided, and disableBodyScroll must not have been | ||
// called on this targetElement before. | ||
if (!targetElement) { | ||
// eslint-disable-next-line no-console | ||
console.error('disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.'); | ||
return; | ||
} | ||
// targetElement must be provided | ||
if (!targetElement) { | ||
// eslint-disable-next-line no-console | ||
console.error('disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.'); | ||
return; | ||
} | ||
if (targetElement && !locks.some(function (lock) { | ||
return lock.targetElement === targetElement; | ||
})) { | ||
var lock = { | ||
targetElement: targetElement, | ||
options: options || {} | ||
}; | ||
// disableBodyScroll must not have been called on this targetElement before | ||
if (locks.some(function (lock) { | ||
return lock.targetElement === targetElement; | ||
})) { | ||
return; | ||
} | ||
locks = [].concat(_toConsumableArray(locks), [lock]); | ||
var lock = { | ||
targetElement: targetElement, | ||
options: options || {} | ||
}; | ||
targetElement.ontouchstart = function (event) { | ||
if (event.targetTouches.length === 1) { | ||
// detect single touch. | ||
initialClientY = event.targetTouches[0].clientY; | ||
} | ||
}; | ||
targetElement.ontouchmove = function (event) { | ||
if (event.targetTouches.length === 1) { | ||
// detect single touch. | ||
handleScroll(event, targetElement); | ||
} | ||
}; | ||
locks = [].concat(_toConsumableArray(locks), [lock]); | ||
if (!documentListenerAdded) { | ||
document.addEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined); | ||
documentListenerAdded = true; | ||
if (isIosDevice) { | ||
targetElement.ontouchstart = function (event) { | ||
if (event.targetTouches.length === 1) { | ||
// detect single touch. | ||
initialClientY = event.targetTouches[0].clientY; | ||
} | ||
}; | ||
targetElement.ontouchmove = function (event) { | ||
if (event.targetTouches.length === 1) { | ||
// detect single touch. | ||
handleScroll(event, targetElement); | ||
} | ||
}; | ||
if (!documentListenerAdded) { | ||
document.addEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined); | ||
documentListenerAdded = true; | ||
} | ||
} else { | ||
setOverflowHidden(options); | ||
var _lock = { | ||
targetElement: targetElement, | ||
options: options || {} | ||
}; | ||
locks = [].concat(_toConsumableArray(locks), [_lock]); | ||
} | ||
@@ -224,4 +212,2 @@ }; | ||
locks = []; | ||
// Reset initial clientY. | ||
@@ -231,33 +217,28 @@ initialClientY = -1; | ||
restoreOverflowSetting(); | ||
locks = []; | ||
} | ||
locks = []; | ||
}; | ||
var enableBodyScroll = exports.enableBodyScroll = function enableBodyScroll(targetElement) { | ||
if (!targetElement) { | ||
// eslint-disable-next-line no-console | ||
console.error('enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.'); | ||
return; | ||
} | ||
locks = locks.filter(function (lock) { | ||
return lock.targetElement !== targetElement; | ||
}); | ||
if (isIosDevice) { | ||
if (!targetElement) { | ||
// eslint-disable-next-line no-console | ||
console.error('enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.'); | ||
return; | ||
} | ||
targetElement.ontouchstart = null; | ||
targetElement.ontouchmove = null; | ||
locks = locks.filter(function (lock) { | ||
return lock.targetElement !== targetElement; | ||
}); | ||
if (documentListenerAdded && locks.length === 0) { | ||
document.removeEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined); | ||
documentListenerAdded = false; | ||
} | ||
} else { | ||
locks = locks.filter(function (lock) { | ||
return lock.targetElement !== targetElement; | ||
}); | ||
if (!locks.length) { | ||
restoreOverflowSetting(); | ||
} | ||
} else if (!locks.length) { | ||
restoreOverflowSetting(); | ||
} | ||
@@ -264,0 +245,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){if("function"==typeof define&&define.amd)define(["exports"],t);else if("undefined"!=typeof exports)t(exports);else{var o={};t(o),e.bodyScrollLock=o}}(this,function(exports){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,o=Array(e.length);t<e.length;t++)o[t]=e[t];return o}return Array.from(e)}Object.defineProperty(exports,"__esModule",{value:!0});var i=!1;if("undefined"!=typeof window){var e={get passive(){i=!0}};window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}function l(t){return u.some(function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(t))})}function d(e){var t=e||window.event;return!!l(t.target)||(1<t.touches.length||(t.preventDefault&&t.preventDefault(),!1))}function o(){setTimeout(function(){void 0!==f&&(document.body.style.paddingRight=f,f=void 0),void 0!==v&&(document.body.style.overflow=v,v=void 0)})}var c="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&1<window.navigator.maxTouchPoints),u=[],a=!1,s=-1,v=void 0,f=void 0;exports.disableBodyScroll=function(r,e){if(c){if(!r)return void console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");if(r&&!u.some(function(e){return e.targetElement===r})){var t={targetElement:r,options:e||{}};u=[].concat(n(u),[t]),r.ontouchstart=function(e){1===e.targetTouches.length&&(s=e.targetTouches[0].clientY)},r.ontouchmove=function(e){var t,o,n,i;1===e.targetTouches.length&&(o=r,i=(t=e).targetTouches[0].clientY-s,l(t.target)||(o&&0===o.scrollTop&&0<i||(n=o)&&n.scrollHeight-n.scrollTop<=n.clientHeight&&i<0?d(t):t.stopPropagation()))},a||(document.addEventListener("touchmove",d,i?{passive:!1}:void 0),a=!0)}}else{!function(e){if(void 0===f){var t=!!e&&!0===e.reserveScrollBarGap,o=window.innerWidth-document.documentElement.clientWidth;t&&0<o&&(f=document.body.style.paddingRight,document.body.style.paddingRight=o+"px")}void 0===v&&(v=document.body.style.overflow,setTimeout(function(){document.body.style.overflow="hidden"}))}(e);var o={targetElement:r,options:e||{}};u=[].concat(n(u),[o])}},exports.clearAllBodyScrollLocks=function(){c?(u.forEach(function(e){e.targetElement.ontouchstart=null,e.targetElement.ontouchmove=null}),a&&(document.removeEventListener("touchmove",d,i?{passive:!1}:void 0),a=!1),u=[],s=-1):(o(),u=[])},exports.enableBodyScroll=function(t){if(c){if(!t)return void console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");t.ontouchstart=null,t.ontouchmove=null,u=u.filter(function(e){return e.targetElement!==t}),a&&0===u.length&&(document.removeEventListener("touchmove",d,i?{passive:!1}:void 0),a=!1)}else(u=u.filter(function(e){return e.targetElement!==t})).length||o()}}); | ||
!function(e,o){if("function"==typeof define&&define.amd)define(["exports"],o);else if("undefined"!=typeof exports)o(exports);else{var t={};o(t),e.bodyScrollLock=t}}(this,function(exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=!1;if("undefined"!=typeof window){var e={get passive(){t=!0}};window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}function l(o){return c.some(function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(o))})}function d(e){var o=e||window.event;return!!l(o.target)||(1<o.touches.length||(o.preventDefault&&o.preventDefault(),!1))}function n(){void 0!==v&&(document.body.style.paddingRight=v,v=void 0),void 0!==s&&(document.body.style.overflow=s,s=void 0)}var i="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&1<window.navigator.maxTouchPoints),c=[],a=!1,u=-1,s=void 0,v=void 0;exports.disableBodyScroll=function(r,e){if(r){if(!c.some(function(e){return e.targetElement===r})){var o={targetElement:r,options:e||{}};c=[].concat(function(e){if(Array.isArray(e)){for(var o=0,t=Array(e.length);o<e.length;o++)t[o]=e[o];return t}return Array.from(e)}(c),[o]),i?(r.ontouchstart=function(e){1===e.targetTouches.length&&(u=e.targetTouches[0].clientY)},r.ontouchmove=function(e){var o,t,n,i;1===e.targetTouches.length&&(t=r,i=(o=e).targetTouches[0].clientY-u,l(o.target)||(t&&0===t.scrollTop&&0<i||(n=t)&&n.scrollHeight-n.scrollTop<=n.clientHeight&&i<0?d(o):o.stopPropagation()))},a||(document.addEventListener("touchmove",d,t?{passive:!1}:void 0),a=!0)):function(e){if(void 0===v){var o=!!e&&!0===e.reserveScrollBarGap,t=window.innerWidth-document.documentElement.clientWidth;o&&0<t&&(v=document.body.style.paddingRight,document.body.style.paddingRight=t+"px")}void 0===s&&(s=document.body.style.overflow,document.body.style.overflow="hidden")}(e)}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},exports.clearAllBodyScrollLocks=function(){i?(c.forEach(function(e){e.targetElement.ontouchstart=null,e.targetElement.ontouchmove=null}),a&&(document.removeEventListener("touchmove",d,t?{passive:!1}:void 0),a=!1),u=-1):n(),c=[]},exports.enableBodyScroll=function(o){o?(c=c.filter(function(e){return e.targetElement!==o}),i?(o.ontouchstart=null,o.ontouchmove=null,a&&0===c.length&&(document.removeEventListener("touchmove",d,t?{passive:!1}:void 0),a=!1)):c.length||n()):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")}}); |
{ | ||
"name": "body-scroll-lock", | ||
"version": "3.1.3", | ||
"version": "3.1.4", | ||
"description": "Enables body scroll locking (for iOS Mobile and Tablet, Android, desktop Safari/Chrome/Firefox) without breaking scrolling of a target element (eg. modal/lightbox/flyouts/nav-menus)", | ||
@@ -5,0 +5,0 @@ "main": "lib/bodyScrollLock.min.js", |
@@ -264,3 +264,3 @@ <p align="left"> <img width="675" src="https://raw.githubusercontent.com/willmcpo/body-scroll-lock/master/images/logo.png" alt="Body scroll lock...just works with everything ;-)" /> </p> | ||
el = el.parentNode; | ||
el = el.parentElement; | ||
} | ||
@@ -267,0 +267,0 @@ }, |
37795
542