fix(editor): Fix canvas moving check (#17856)

This commit is contained in:
Suguru Inoue
2025-07-31 12:28:46 +02:00
committed by GitHub
parent 34991d6f58
commit ddc4c0b7d9
5 changed files with 27 additions and 38 deletions

View File

@@ -196,15 +196,18 @@ const classes = computed(() => ({
const panningKeyCode = ref<string[] | true>(isMobileDevice ? true : [' ', controlKeyCode]);
const panningMouseButton = ref<number[] | true>(isMobileDevice ? true : [1]);
const selectionKeyCode = ref<string | true | null>(isMobileDevice ? 'Shift' : true);
const isInPanningMode = ref(false);
function switchToPanningMode() {
selectionKeyCode.value = null;
panningMouseButton.value = [0, 1];
isInPanningMode.value = true;
}
function switchToSelectionMode() {
selectionKeyCode.value = true;
panningMouseButton.value = [1];
isInPanningMode.value = false;
}
onKeyDown(panningKeyCode.value, switchToPanningMode, {
@@ -651,8 +654,13 @@ function setReadonly(value: boolean) {
elementsSelectable.value = true;
}
function onPaneMoveStart() {
isPaneMoving.value = true;
function onPaneMove({ event }: { event: unknown }) {
// The event object is either D3ZoomEvent or WheelEvent.
// Here I'm ignoring D3ZoomEvent because it's not necessarily followed by a moveEnd event.
// This can be simplified once https://github.com/bcakmakoglu/vue-flow/issues/1908 is resolved
if (isInPanningMode.value || event instanceof WheelEvent) {
isPaneMoving.value = true;
}
}
function onPaneMoveEnd() {
@@ -894,6 +902,7 @@ provide(CanvasKey, {
initialized,
viewport,
isExperimentalNdvActive,
isPaneMoving,
});
</script>
@@ -923,7 +932,7 @@ provide(CanvasKey, {
@connect-end="onConnectEnd"
@pane-click="onClickPane"
@pane-context-menu="onOpenContextMenu"
@move-start="onPaneMoveStart"
@move="onPaneMove"
@move-end="onPaneMoveEnd"
@node-drag-stop="onNodeDragStop"
@node-click="onNodeClick"