Merge pull request #3218 from Human-Connection/2607-fix-layout-shift

fix: layout shift [2607]
This commit is contained in:
Robert Schäfer 2020-03-10 13:01:22 +01:00 committed by GitHub
commit d18e14a9be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,11 +48,23 @@ export default {
if (isOpen) {
this.$nextTick(() => {
setTimeout(() => {
document.getElementsByTagName('body')[0].classList.add('dropdown-open')
const paddingRightStyle = `${window.innerWidth -
document.documentElement.clientWidth}px`
const navigationElement = document.querySelector('.main-navigation')
document.body.style.paddingRight = paddingRightStyle
document.body.classList.add('dropdown-open')
if (navigationElement) {
navigationElement.style.paddingRight = paddingRightStyle
}
}, 20)
})
} else {
document.getElementsByTagName('body')[0].classList.remove('dropdown-open')
const navigationElement = document.querySelector('.main-navigation')
document.body.style.paddingRight = null
document.body.classList.remove('dropdown-open')
if (navigationElement) {
navigationElement.style.paddingRight = null
}
}
} catch (err) {}
},