recalculate position on scrolls

This commit is contained in:
Henry Jameson 2022-06-13 01:30:20 +03:00
parent 8979548ed8
commit 85de0927fa
1 changed files with 10 additions and 6 deletions

View File

@ -195,8 +195,8 @@ const Popover = {
if (this.$el.contains(e.target)) return if (this.$el.contains(e.target)) return
this.hidePopover() this.hidePopover()
}, },
onScroll () { onScroll (e) {
this.hidePopover() this.updateStyles()
} }
}, },
updated () { updated () {
@ -210,13 +210,17 @@ const Popover = {
this.oldSize = { width: content.offsetWidth, height: content.offsetHeight } this.oldSize = { width: content.offsetWidth, height: content.offsetHeight }
} }
}, },
created () { mounted () {
let scrollable = this.$refs.trigger.closest('.column.-scrollable')
if (!scrollable) scrollable = window
document.addEventListener('click', this.onClickOutside) document.addEventListener('click', this.onClickOutside)
window.addEventListener('scroll', this.onScroll) scrollable.addEventListener('scroll', this.onScroll)
}, },
unmounted () { beforeUnmount () {
let scrollable = this.$refs.trigger.closest('.column.-scrollable')
if (!scrollable) scrollable = window
document.removeEventListener('click', this.onClickOutside) document.removeEventListener('click', this.onClickOutside)
window.removeEventListener('scroll', this.onScroll) scrollable.removeEventListener('scroll', this.onScroll)
this.hidePopover() this.hidePopover()
} }
} }