This commit is contained in:
parent
485f89d262
commit
718021f15c
|
@ -39,11 +39,11 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkSwitchButton :class="$style.switchButton" :checked="item.ref" :disabled="item.disabled" @toggle="switchItem(item)" />
|
<MkSwitchButton :class="$style.switchButton" :checked="item.ref" :disabled="item.disabled" @toggle="switchItem(item)" />
|
||||||
<span :class="$style.switchText">{{ item.text }}</span>
|
<span :class="$style.switchText">{{ item.text }}</span>
|
||||||
</button>
|
</button>
|
||||||
<button v-else-if="item.type === 'parent'" class="_button" role="menuitem" :tabindex="i" :class="[$style.item, $style.parent, { [$style.childShowing]: childShowingItem === item }]" @mouseenter.stop="showChildren(item, $event)">
|
<div v-else-if="item.type === 'parent'" role="menuitem" :tabindex="i" :class="[$style.item, $style.parent, { [$style.childShowing]: childShowingItem === item }]" @mousedown.stop="showChildren(item, $event)">
|
||||||
<i v-if="item.icon" class="ti-fw" :class="[$style.icon, item.icon]"></i>
|
<i v-if="item.icon" class="ti-fw" :class="[$style.icon, item.icon]"></i>
|
||||||
<span>{{ item.text }}</span>
|
<span>{{ item.text }}</span>
|
||||||
<span :class="$style.caret"><i class="ti ti-chevron-right ti-fw"></i></span>
|
<span :class="$style.caret"><i class="ti ti-chevron-right ti-fw"></i></span>
|
||||||
</button>
|
</div>
|
||||||
<button v-else :tabindex="i" class="_button" role="menuitem" :class="[$style.item, { [$style.danger]: item.danger, [$style.active]: item.active }]" :disabled="item.active" @click="clicked(item.action, $event)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
|
<button v-else :tabindex="i" class="_button" role="menuitem" :class="[$style.item, { [$style.danger]: item.danger, [$style.active]: item.active }]" :disabled="item.active" @click="clicked(item.action, $event)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
|
||||||
<i v-if="item.icon" class="ti-fw" :class="[$style.icon, item.icon]"></i>
|
<i v-if="item.icon" class="ti-fw" :class="[$style.icon, item.icon]"></i>
|
||||||
<MkAvatar v-if="item.avatar" :user="item.avatar" :class="$style.avatar"/>
|
<MkAvatar v-if="item.avatar" :user="item.avatar" :class="$style.avatar"/>
|
||||||
|
@ -136,6 +136,7 @@ function childActioned() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onGlobalMousedown(event: MouseEvent) {
|
function onGlobalMousedown(event: MouseEvent) {
|
||||||
|
console.log('globalmousedown')
|
||||||
if (childTarget && (event.target === childTarget || childTarget.contains(event.target))) return;
|
if (childTarget && (event.target === childTarget || childTarget.contains(event.target))) return;
|
||||||
if (child && child.checkHit(event)) return;
|
if (child && child.checkHit(event)) return;
|
||||||
closeChild();
|
closeChild();
|
||||||
|
@ -152,6 +153,8 @@ function onItemMouseLeave(item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function showChildren(item: MenuParent, ev: MouseEvent) {
|
async function showChildren(item: MenuParent, ev: MouseEvent) {
|
||||||
|
console.log(ev);
|
||||||
|
if (props.asDrawer && childrenCache.has(item)) return;
|
||||||
const children: Ref<(MenuItem | MenuPending)[]> = ref([]);
|
const children: Ref<(MenuItem | MenuPending)[]> = ref([]);
|
||||||
if (!item.noCache && childrenCache.has(item)) {
|
if (!item.noCache && childrenCache.has(item)) {
|
||||||
children.value = childrenCache.get(item)!;
|
children.value = childrenCache.get(item)!;
|
||||||
|
@ -171,6 +174,7 @@ async function showChildren(item: MenuParent, ev: MouseEvent) {
|
||||||
|
|
||||||
if (props.asDrawer) {
|
if (props.asDrawer) {
|
||||||
os.popupMenu(children as Ref<MenuItem[]>, ev.currentTarget ?? ev.target).finally(() => {
|
os.popupMenu(children as Ref<MenuItem[]>, ev.currentTarget ?? ev.target).finally(() => {
|
||||||
|
childrenCache.delete(item);
|
||||||
console.log('child drawer close');
|
console.log('child drawer close');
|
||||||
emit('close');
|
emit('close');
|
||||||
});
|
});
|
||||||
|
@ -182,6 +186,10 @@ async function showChildren(item: MenuParent, ev: MouseEvent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onmousedown(ev: MouseEvent) {
|
||||||
|
ev.stopImmediatePropagation();
|
||||||
|
}
|
||||||
|
|
||||||
function clicked(fn: MenuAction, ev: MouseEvent) {
|
function clicked(fn: MenuAction, ev: MouseEvent) {
|
||||||
fn(ev);
|
fn(ev);
|
||||||
close(true);
|
close(true);
|
||||||
|
|
|
@ -33,7 +33,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
:duration="transitionDuration" appear @afterLeave="afterLeave" @enter="emit('opening')" @afterEnter="onOpened"
|
:duration="transitionDuration" appear @afterLeave="afterLeave" @enter="emit('opening')" @afterEnter="onOpened"
|
||||||
>
|
>
|
||||||
<div v-show="manualShowing != null ? manualShowing : showing" v-hotkey.global="keymap" :class="[$style.root, { [$style.drawer]: type === 'drawer', [$style.dialog]: type === 'dialog', [$style.popup]: type === 'popup' }]" :style="{ zIndex, pointerEvents: (manualShowing != null ? manualShowing : showing) ? 'auto' : 'none', '--transformOrigin': transformOrigin }">
|
<div v-show="manualShowing != null ? manualShowing : showing" v-hotkey.global="keymap" :class="[$style.root, { [$style.drawer]: type === 'drawer', [$style.dialog]: type === 'dialog', [$style.popup]: type === 'popup' }]" :style="{ zIndex, pointerEvents: (manualShowing != null ? manualShowing : showing) ? 'auto' : 'none', '--transformOrigin': transformOrigin }">
|
||||||
<div data-cy-bg :data-cy-transparent="isEnableBgTransparent" class="_modalBg" :class="[$style.bg, { [$style.bgTransparent]: isEnableBgTransparent }]" :style="{ zIndex }" @click="onBgClick" @mousedown="onBgClick" @contextmenu.prevent.stop="() => {}"></div>
|
<div data-cy-bg :data-cy-transparent="isEnableBgTransparent" class="_modalBg" :class="[$style.bg, { [$style.bgTransparent]: isEnableBgTransparent }]" :style="{ zIndex }" @click="onBgClick" @mousedown.self="onBgClick" @contextmenu.prevent.stop="() => {}"></div>
|
||||||
<div ref="content" :class="[$style.content, { [$style.fixed]: fixed }]" :style="{ zIndex }" @click.self="onBgClick">
|
<div ref="content" :class="[$style.content, { [$style.fixed]: fixed }]" :style="{ zIndex }" @click.self="onBgClick">
|
||||||
<slot :max-height="maxHeight" :type="type"></slot>
|
<slot :max-height="maxHeight" :type="type"></slot>
|
||||||
</div>
|
</div>
|
||||||
|
@ -161,7 +161,7 @@ function afterLeave() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onBgClick(e) {
|
function onBgClick(e) {
|
||||||
console.log(e);
|
console.log(e, contentClicking);
|
||||||
if (contentClicking) return;
|
if (contentClicking) return;
|
||||||
emit('click');
|
emit('click');
|
||||||
}
|
}
|
||||||
|
@ -296,14 +296,17 @@ const onOpened = () => {
|
||||||
// モーダルコンテンツにマウスボタンが押され、コンテンツ外でマウスボタンが離されたときにモーダルバックグラウンドクリックと判定させないためにマウスイベントを監視しフラグ管理する
|
// モーダルコンテンツにマウスボタンが押され、コンテンツ外でマウスボタンが離されたときにモーダルバックグラウンドクリックと判定させないためにマウスイベントを監視しフラグ管理する
|
||||||
const el = content!.children[0];
|
const el = content!.children[0];
|
||||||
el.addEventListener('mousedown', ev => {
|
el.addEventListener('mousedown', ev => {
|
||||||
|
ev.stopPropagation();
|
||||||
|
console.log('mousedown');
|
||||||
contentClicking = true;
|
contentClicking = true;
|
||||||
window.addEventListener('mouseup', ev => {
|
window.addEventListener('mouseup', ev => {
|
||||||
|
console.log('mouseup');
|
||||||
// click イベントより先に mouseup イベントが発生するかもしれないのでちょっと待つ
|
// click イベントより先に mouseup イベントが発生するかもしれないのでちょっと待つ
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
contentClicking = false;
|
contentClicking = false;
|
||||||
}, 100);
|
}, 100);
|
||||||
}, { passive: true, once: true });
|
}, { passive: true, once: true });
|
||||||
}, { passive: true });
|
}, { passive: true, capture: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
const alignObserver = new ResizeObserver((entries, observer) => {
|
const alignObserver = new ResizeObserver((entries, observer) => {
|
||||||
|
|
Loading…
Reference in New Issue