remove scrollbar gutter for Chrome when body scroll is locked

zio/stable
Alexander K 2024-03-17 22:20:50 +01:00
parent 0e3b2633b9
commit 54dd4af312
1 changed files with 2 additions and 0 deletions

View File

@ -6,6 +6,7 @@ let refCount = 0
function incrementRefCount() { function incrementRefCount() {
if (refCount === 0) { if (refCount === 0) {
document.body.style.overflow = 'hidden' document.body.style.overflow = 'hidden'
document.documentElement.style.scrollbarGutter = 'auto'
} }
refCount++ refCount++
} }
@ -14,6 +15,7 @@ function decrementRefCount() {
refCount-- refCount--
if (refCount === 0) { if (refCount === 0) {
document.body.style.overflow = '' document.body.style.overflow = ''
document.documentElement.style.scrollbarGutter = ''
} }
} }