From 3e91159bc3db0967f4afcf2582ba71bda296159e Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 25 Feb 2018 02:57:19 +0900 Subject: :v: --- .../app/common/views/components/autocomplete.vue | 25 ++++++++++++++++++++-- .../views/components/messaging-room.form.vue | 8 ++++++- .../app/common/views/components/messaging-room.vue | 13 ----------- 3 files changed, 30 insertions(+), 16 deletions(-) (limited to 'src/web/app/common/views/components') diff --git a/src/web/app/common/views/components/autocomplete.vue b/src/web/app/common/views/components/autocomplete.vue index 1980804927..b068ecc4fa 100644 --- a/src/web/app/common/views/components/autocomplete.vue +++ b/src/web/app/common/views/components/autocomplete.vue @@ -22,7 +22,7 @@ import * as pictograph from 'pictograph'; import contains from '../../../common/scripts/contains'; export default Vue.extend({ - props: ['type', 'q', 'textarea', 'complete', 'close'], + props: ['type', 'q', 'textarea', 'complete', 'close', 'x', 'y'], data() { return { fetching: true, @@ -37,6 +37,27 @@ export default Vue.extend({ return (this.$refs.suggests as Element).children; } }, + updated() { + //#region 位置調整 + const margin = 32; + + if (this.x + this.$el.offsetWidth > window.innerWidth - margin) { + this.$el.style.left = (this.x - this.$el.offsetWidth) + 'px'; + this.$el.style.marginLeft = '-16px'; + } else { + this.$el.style.left = this.x + 'px'; + this.$el.style.marginLeft = '0'; + } + + if (this.y + this.$el.offsetHeight > window.innerHeight - margin) { + this.$el.style.top = (this.y - this.$el.offsetHeight) + 'px'; + this.$el.style.marginTop = '0'; + } else { + this.$el.style.top = this.y + 'px'; + this.$el.style.marginTop = 'calc(1em + 8px)'; + } + //#endregion + }, mounted() { this.textarea.addEventListener('keydown', this.onKeydown); @@ -136,7 +157,7 @@ export default Vue.extend({ -- cgit v1.2.3-freya