From 5b3ffa20efd6110afbb74fe46165f2638c648615 Mon Sep 17 00:00:00 2001 From: Martin Denk Date: Wed, 28 Jul 2021 16:33:20 +0200 Subject: [PATCH] fix: add px to positional css values for ios devices --- lib/bodyScrollLock.es6.js | 6 +++--- lib/bodyScrollLock.esm.js | 6 +++--- lib/bodyScrollLock.js | 6 +++--- lib/bodyScrollLock.min.js | 2 +- src/bodyScrollLock.js | 10 +++++----- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/bodyScrollLock.es6.js b/lib/bodyScrollLock.es6.js index 4500f7f5..fa4f42b9 100644 --- a/lib/bodyScrollLock.es6.js +++ b/lib/bodyScrollLock.es6.js @@ -102,11 +102,11 @@ const setPositionFixed = () => window.requestAnimationFrame(() => { left: document.body.style.left }; - // Update the dom inside an animation frame + // Update the dom inside an animation frame const { scrollY, scrollX, innerHeight } = window; document.body.style.position = 'fixed'; - document.body.style.top = -scrollY; - document.body.style.left = -scrollX; + document.body.style.top = `${-scrollY}px`; + document.body.style.left = `${-scrollX}px`; setTimeout(() => window.requestAnimationFrame(() => { // Attempt to check if the bottom bar appeared due to the position change diff --git a/lib/bodyScrollLock.esm.js b/lib/bodyScrollLock.esm.js index 7a122dac..23518372 100644 --- a/lib/bodyScrollLock.esm.js +++ b/lib/bodyScrollLock.esm.js @@ -105,15 +105,15 @@ var setPositionFixed = function setPositionFixed() { left: document.body.style.left }; - // Update the dom inside an animation frame + // Update the dom inside an animation frame var _window = window, scrollY = _window.scrollY, scrollX = _window.scrollX, innerHeight = _window.innerHeight; document.body.style.position = 'fixed'; - document.body.style.top = -scrollY; - document.body.style.left = -scrollX; + document.body.style.top = -scrollY + 'px'; + document.body.style.left = -scrollX + 'px'; setTimeout(function () { return window.requestAnimationFrame(function () { diff --git a/lib/bodyScrollLock.js b/lib/bodyScrollLock.js index 66fff488..a8dfa1f1 100644 --- a/lib/bodyScrollLock.js +++ b/lib/bodyScrollLock.js @@ -134,15 +134,15 @@ left: document.body.style.left }; - // Update the dom inside an animation frame + // Update the dom inside an animation frame var _window = window, scrollY = _window.scrollY, scrollX = _window.scrollX, innerHeight = _window.innerHeight; document.body.style.position = 'fixed'; - document.body.style.top = -scrollY; - document.body.style.left = -scrollX; + document.body.style.top = -scrollY + 'px'; + document.body.style.left = -scrollX + 'px'; setTimeout(function () { return window.requestAnimationFrame(function () { diff --git a/lib/bodyScrollLock.min.js b/lib/bodyScrollLock.min.js index 3e31785c..c2f200f5 100644 --- a/lib/bodyScrollLock.min.js +++ b/lib/bodyScrollLock.min.js @@ -1 +1 @@ -!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 d(o){return s.some(function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(o))})}function l(e){var o=e||window.event;return!!d(o.target)||(1 window.requestAnimationFrame(() => { top: document.body.style.top, left: document.body.style.left }; - - // Update the dom inside an animation frame + + // Update the dom inside an animation frame const { scrollY, scrollX, innerHeight } = window; document.body.style.position = 'fixed'; - document.body.style.top = -scrollY; - document.body.style.left = -scrollX; + document.body.style.top = `${-scrollY}px`; + document.body.style.left = `${-scrollX}px`; setTimeout(() => window.requestAnimationFrame(() => { // Attempt to check if the bottom bar appeared due to the position change @@ -241,7 +241,7 @@ export const clearAllBodyScrollLocks = (): void => { // Reset initial clientY. initialClientY = -1; } - + if (isIosDevice) { restorePositionSetting(); } else {