enhance(frontend): improve ux of deck scroll

This commit is contained in:
syuilo 2023-06-24 12:58:26 +09:00 committed by naskya
parent c63f56f79b
commit 65d0e8f683
No known key found for this signature in database
GPG Key ID: 164DFF24E2D40139
2 changed files with 12 additions and 10 deletions

View File

@ -9,6 +9,7 @@
class="columns"
:class="deckStore.reactiveState.columnAlign.value"
@contextmenu.self.prevent="onContextmenu"
@wheel.self="onWheel"
>
<template v-for="ids in layout">
<!-- sectionを利用しているのはdeck.vue側でcolumnに対してfirst-of-typeを効かせるため -->
@ -31,6 +32,7 @@
) + 'px',
}
"
@wheel.self="onWheel"
>
<DeckColumnCore
v-for="id in ids"
@ -50,6 +52,7 @@
:is-stacked="false"
:style="columns.find(c => c.id === ids[0])!.flexible ? { flex: 1, minWidth: '350px' } : { width: columns.find(c => c.id === ids[0])!.width + 'px' }"
@parent-focus="moveFocus(ids[0], $event)"
@headerWheel="onWheel"
/>
</template>
<div v-if="layout.length === 0" class="intro _panel">
@ -279,18 +282,15 @@ const onContextmenu = (ev) => {
);
};
document.documentElement.style.overflowY = "hidden";
document.documentElement.style.scrollBehavior = "auto";
window.addEventListener("wheel", (ev) => {
if (ev.target === columnsEl && ev.deltaX === 0) {
columnsEl.scrollLeft += ev.deltaY;
} else if (
getScrollContainer(ev.target as HTMLElement) == null &&
ev.deltaX === 0
) {
function onWheel(ev: WheelEvent) {
if (ev.deltaX === 0) {
columnsEl.scrollLeft += ev.deltaY;
}
});
}
document.documentElement.style.overflowY = "hidden";
document.documentElement.style.scrollBehavior = "auto";
loadDeck();
function moveFocus(id: string, direction: "up" | "down" | "left" | "right") {

View File

@ -23,6 +23,7 @@
@dragstart="onDragstart"
@dragend="onDragend"
@contextmenu.prevent.stop="onContextmenu"
@wheel="emit('headerWheel', $event)"
>
<button
v-if="isStacked && !isMainColumn"
@ -95,6 +96,7 @@ const props = withDefaults(
const emit = defineEmits<{
(ev: "parent-focus", direction: "up" | "down" | "left" | "right"): void;
(ev: "change-active-state", v: boolean): void;
(ev: "headerWheel", ctx: WheelEvent): void;
}>();
let body = $ref<HTMLDivElement>();