Merge pull request '[PR]: fix: scrolling in deck view' (#10359) from naskya/calckey:fix/deck-scroll into develop

Reviewed-on: https://codeberg.org/calckey/calckey/pulls/10359
This commit is contained in:
Kainoa Kanter 2023-06-24 21:14:09 +00:00
commit 5e69b2c5aa
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>();