Commit dc766c1d authored by Tae Hoon's avatar Tae Hoon

query form elements from the store

parent cce94ac3
......@@ -34,6 +34,9 @@ const FloatingPostButton = {
},
autohideFloatingPostButton () {
return !!this.$store.getters.mergedConfig.autohideFloatingPostButton
},
postStatusForms () {
return this.$store.state.interface.postStatusForms
}
},
watch: {
......@@ -43,6 +46,9 @@ const FloatingPostButton = {
} else {
this.deactivateFloatingPostButtonAutohide()
}
},
postStatusForms () {
this.$nextTick(() => this.checkHoverInlineReply())
}
},
methods: {
......@@ -50,13 +56,11 @@ const FloatingPostButton = {
window.addEventListener('scroll', this.handleScrollStart)
window.addEventListener('scroll', this.handleScrollEnd)
window.addEventListener('resize', this.handleResize)
window.addEventListener('toggleInlineReply', this.handleToggleInlineReply)
},
deactivateFloatingPostButtonAutohide () {
window.removeEventListener('scroll', this.handleScrollStart)
window.removeEventListener('scroll', this.handleScrollEnd)
window.removeEventListener('resize', this.handleResize)
window.removeEventListener('toggleInlineReply', this.handleToggleInlineReply)
},
openPostForm () {
this.$store.dispatch('openPostStatusModal')
......@@ -82,9 +86,8 @@ const FloatingPostButton = {
}
},
checkHoverInlineReply () {
const formElems = document.querySelectorAll('.post-status-form.reply-body')
for (let i = 0; i < formElems.length; i++) {
const rect = formElems.item(i).getBoundingClientRect()
for (let i = 0; i < this.postStatusForms.length; i++) {
const rect = this.postStatusForms[i].getBoundingClientRect()
if (
rect.bottom > window.innerHeight + buttonRect.bottom - buttonRect.height &&
rect.right > window.innerWidth + buttonRect.right - buttonRect.width &&
......@@ -116,11 +119,7 @@ const FloatingPostButton = {
handleResize: debounce(function () {
this.handleOSK()
this.checkHoverInlineReply()
}, 100),
handleToggleInlineReply () {
this.$nextTick(() => this.checkHoverInlineReply())
}
}, 100)
}
}
......
......@@ -379,6 +379,9 @@ const PostStatusForm = {
},
dismissScopeNotice () {
this.$store.dispatch('setOption', { name: 'hideScopeNotice', value: true })
},
getBoundingClientRect () {
return this.$refs.root.getBoundingClientRect()
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment