Fixed #4589 - Improve block/unblockScroll architecture

This commit is contained in:
mertsincan 2023-10-10 23:36:20 +01:00
parent b85876be95
commit 4fa7741923
9 changed files with 36 additions and 43 deletions

View file

@ -564,6 +564,10 @@ export default {
return scrollbarWidth;
},
calculateBodyScrollbarWidth() {
return window.innerWidth - document.documentElement.offsetWidth;
},
getBrowser() {
if (!this.browser) {
let matched = this.resolveUserAgent();
@ -755,5 +759,15 @@ export default {
window.open(encodeURI(csv));
}
}
},
blockBodyScroll(className = 'p-overflow-hidden') {
document.body.style.setProperty('--scrollbar-width', this.calculateBodyScrollbarWidth() + 'px');
this.addClass(document.body, className);
},
unblockBodyScroll(className = 'p-overflow-hidden') {
document.body.style.removeProperty('--scrollbar-width');
this.removeClass(document.body, className);
}
};