chore: improve reaction picker behaviour

This commit is contained in:
syuilo 2021-02-28 02:22:53 +09:00
parent 764a158cd7
commit 7674a62d40
2 changed files with 63 additions and 61 deletions

View File

@ -69,15 +69,24 @@ export default defineComponent({
mounted() {
this.$watch('src', () => {
this.fixed = getFixedContainer(this.src) != null;
this.$nextTick(() => {
this.align();
});
}, { immediate: true });
this.$nextTick(() => {
const popover = this.$refs.content as any;
// TODO: ResizeObserver
new ResizeObserver((entries, observer) => {
this.align();
}).observe(popover);
});
},
methods: {
align() {
if (!this.popup) return;
const popover = this.$refs.content as any;
const rect = this.src.getBoundingClientRect();
const width = popover.offsetWidth;
@ -130,10 +139,8 @@ export default defineComponent({
popover.style.left = left + 'px';
popover.style.top = top + 'px';
}).observe(popover);
});
},
methods: {
childRendered() {
//
const content = this.$refs.content.children[0];

View File

@ -360,16 +360,12 @@ export async function openEmojiPicker(src?: HTMLElement, opts, initialTextarea:
let reactionPicker = null;
export async function pickReaction(src: HTMLElement, chosen, closed) {
if (reactionPicker) {
if (reactionPicker.opening) return;
reactionPicker.opening = true;
reactionPicker.src.value = src;
reactionPicker.manualShowing.value = true;
reactionPicker.chosen = chosen;
reactionPicker.closed = closed;
} else {
reactionPicker = {
opening: true,
src: ref(src),
manualShowing: ref(true),
chosen, closed
@ -388,7 +384,6 @@ export async function pickReaction(src: HTMLElement, chosen, closed) {
closed: () => {
reactionPicker.src.value = null;
reactionPicker.closed();
reactionPicker.opening = false;
}
});
}