1function BMBodyScrollLock() { 2 var _body = document.querySelector('body'); 3 var _scrollPosition = 0; 4 5 var _initialWindowInnerHeight = 0; 6 7 8 var bodyLockPosition = 'fixed'; 9 try { 10 var ua = window.navigator.userAgent; 11 if (ua.includes('iPhone')) { 12 var m = ua.match(/Version\/(?<ver>[0-9\.]+)/); 13 var version = parseFloat(m.groups.ver); 14 if (!isNaN(version) && version < 16) { 15 bodyLockPosition = 'absolute'; 16 } 17 } 18 } 19 catch (e) { } 20 21 22 window.BMBodyScrollLock_LockCounter = window.BMBodyScrollLock_LockCounter || 0; 23 24 this.lock = function () { 25 document.addEventListener('touchmove', onTouchMove); 26 27 window.BMBodyScrollLock_LockCounter++; 28 29 _scrollPosition = window.pageYOffset; 30 _body.style.overflow = 'hidden'; 31 _body.style.position = bodyLockPosition; 32 _body.style.top = '-' + _scrollPosition + 'px'; 33 _body.style.width = '100%'; 34 35 _initialWindowInnerHeight = window.innerHeight; 36 }; 37 38 this.unlock = function () { 39 document.removeEventListener('touchmove', onTouchMove); 40 41 window.BMBodyScrollLock_LockCounter--; 42 if (window.BMBodyScrollLock_LockCounter > 0) { 43 return; 44 } 45 46 _body.style.removeProperty('overflow'); 47 _body.style.removeProperty('position'); 48 _body.style.removeProperty('top'); 49 _body.style.removeProperty('width'); 50 window.scrollTo(0, _scrollPosition); 51 }; 52 53 // https://stackoverflow.com/a/50024226 <- scrollTop idea 54 function onTouchMove() { 55 if (window.innerHeight !== _initialWindowInnerHeight) { 56 // keyboard shown (probably) 57 return; 58 } 59 60 _body.scrollTop = 0; 61 } 62}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.