fix(search): remove overflow hidden when searching from homepage

This commit is contained in:
Valentin Kaelin 2020-08-25 18:57:09 +02:00
parent b3b27d0223
commit d1d61073c7

View file

@ -102,20 +102,11 @@ export default {
watch: { watch: {
open(newVal) { open(newVal) {
const header = document.querySelector('.header div')
// Search Dropdown open // Search Dropdown open
if (newVal) { if (newVal) {
if (!this.homepage) { this.dropDownOpening()
document.body.style.marginLeft = `-${this.getScrollbarWidth()}px`
header.style.paddingRight = `${this.getScrollbarWidth()}px`
}
document.body.style.overflow = 'hidden'
} else { } else {
if (!this.homepage) { this.dropDownClosing()
header.style.paddingRight = 0
}
document.body.style.marginLeft = 0
document.body.style.overflow = 'auto'
} }
}, },
$route(newRoute) { $route(newRoute) {
@ -136,9 +127,26 @@ export default {
beforeDestroy() { beforeDestroy() {
window.removeEventListener('blur', this.windowBlur) window.removeEventListener('blur', this.windowBlur)
window.removeEventListener('keydown', this.handleEscape) window.removeEventListener('keydown', this.handleEscape)
this.dropDownClosing()
}, },
methods: { methods: {
dropDownClosing() {
const header = document.querySelector('.header div')
if (!this.homepage && header) {
header.style.paddingRight = 0
}
document.body.style.marginLeft = 0
document.body.style.overflow = 'auto'
},
dropDownOpening() {
const header = document.querySelector('.header div')
if (!this.homepage) {
document.body.style.marginLeft = `-${this.getScrollbarWidth()}px`
header.style.paddingRight = `${this.getScrollbarWidth()}px`
}
document.body.style.overflow = 'hidden'
},
formSubmit() { formSubmit() {
const search = this.summoner.split(' ').join('') const search = this.summoner.split(' ').join('')
if (search.length) { if (search.length) {