mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-21 12:15:31 +02:00
refactor(frontend): refactor deck events (#17290)
This commit is contained in:
@@ -46,11 +46,10 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
import { onBeforeUnmount, onMounted, provide, watch, useTemplateRef, ref, computed } from 'vue';
|
||||
import type { Column } from '@/deck.js';
|
||||
import type { MenuItem } from '@/types/menu.js';
|
||||
import { updateColumn, swapLeftColumn, swapRightColumn, swapUpColumn, swapDownColumn, stackLeftColumn, popRightColumn, removeColumn, swapColumn } from '@/deck.js';
|
||||
import { deckGlobalEvents, updateColumn, swapLeftColumn, swapRightColumn, swapUpColumn, swapDownColumn, stackLeftColumn, popRightColumn, removeColumn, swapColumn } from '@/deck.js';
|
||||
import * as os from '@/os.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { prefer } from '@/preferences.js';
|
||||
import { DI } from '@/di.js';
|
||||
import { checkDragDataType, getDragData, setDragData } from '@/drag-and-drop.js';
|
||||
|
||||
provide('shouldHeaderThin', true);
|
||||
@@ -79,7 +78,7 @@ const emit = defineEmits<{
|
||||
const body = useTemplateRef('body');
|
||||
|
||||
const dragging = ref(false);
|
||||
watch(dragging, v => os.deckGlobalEvents.emit(v ? 'column.dragStart' : 'column.dragEnd'));
|
||||
watch(dragging, v => deckGlobalEvents.emit(v ? 'column.dragStart' : 'column.dragEnd'));
|
||||
|
||||
const draghover = ref(false);
|
||||
const dropready = ref(false);
|
||||
@@ -88,13 +87,13 @@ const isMainColumn = computed(() => props.column.type === 'main');
|
||||
const active = computed(() => props.column.active !== false);
|
||||
|
||||
onMounted(() => {
|
||||
os.deckGlobalEvents.on('column.dragStart', onOtherDragStart);
|
||||
os.deckGlobalEvents.on('column.dragEnd', onOtherDragEnd);
|
||||
deckGlobalEvents.on('column.dragStart', onOtherDragStart);
|
||||
deckGlobalEvents.on('column.dragEnd', onOtherDragEnd);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
os.deckGlobalEvents.off('column.dragStart', onOtherDragStart);
|
||||
os.deckGlobalEvents.off('column.dragEnd', onOtherDragEnd);
|
||||
deckGlobalEvents.off('column.dragStart', onOtherDragStart);
|
||||
deckGlobalEvents.off('column.dragEnd', onOtherDragEnd);
|
||||
});
|
||||
|
||||
function onOtherDragStart() {
|
||||
@@ -306,7 +305,7 @@ function onDragleave() {
|
||||
|
||||
function onDrop(ev: DragEvent) {
|
||||
draghover.value = false;
|
||||
os.deckGlobalEvents.emit('column.dragEnd');
|
||||
deckGlobalEvents.emit('column.dragEnd');
|
||||
|
||||
const id = getDragData(ev, 'deckColumn');
|
||||
if (id != null) {
|
||||
|
||||
Reference in New Issue
Block a user