mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(editor): Show minimap only while panning, zooming or while minimap is hovered (no-changelog) (#10677)
This commit is contained in:
@@ -309,6 +309,7 @@ function emitWithLastSelectedNode(emitFn: (id: string) => void) {
|
||||
|
||||
const defaultZoom = 1;
|
||||
const zoom = ref(defaultZoom);
|
||||
const isPaneMoving = ref(false);
|
||||
|
||||
function getProjectedPosition(event?: MouseEvent) {
|
||||
const bounds = viewportRef.value?.getBoundingClientRect() ?? { left: 0, top: 0 };
|
||||
@@ -354,6 +355,14 @@ function setReadonly(value: boolean) {
|
||||
elementsSelectable.value = true;
|
||||
}
|
||||
|
||||
function onPaneMoveStart() {
|
||||
isPaneMoving.value = true;
|
||||
}
|
||||
|
||||
function onPaneMoveEnd() {
|
||||
isPaneMoving.value = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Context menu
|
||||
*/
|
||||
@@ -414,10 +423,45 @@ function onContextMenuAction(action: ContextMenuAction, nodeIds: string[]) {
|
||||
* Minimap
|
||||
*/
|
||||
|
||||
const minimapVisibilityDelay = 1000;
|
||||
const minimapHideTimeout = ref<NodeJS.Timeout | null>(null);
|
||||
const isMinimapVisible = ref(false);
|
||||
|
||||
function minimapNodeClassnameFn(node: CanvasNode) {
|
||||
return `minimap-node-${node.data?.render.type.replace(/\./g, '-') ?? 'default'}`;
|
||||
}
|
||||
|
||||
watch(isPaneMoving, (value) => {
|
||||
if (value) {
|
||||
showMinimap();
|
||||
} else {
|
||||
hideMinimap();
|
||||
}
|
||||
});
|
||||
|
||||
function showMinimap() {
|
||||
if (minimapHideTimeout.value) {
|
||||
clearTimeout(minimapHideTimeout.value);
|
||||
minimapHideTimeout.value = null;
|
||||
}
|
||||
|
||||
isMinimapVisible.value = true;
|
||||
}
|
||||
|
||||
function hideMinimap() {
|
||||
minimapHideTimeout.value = setTimeout(() => {
|
||||
isMinimapVisible.value = false;
|
||||
}, minimapVisibilityDelay);
|
||||
}
|
||||
|
||||
function onMinimapMouseEnter() {
|
||||
showMinimap();
|
||||
}
|
||||
|
||||
function onMinimapMouseLeave() {
|
||||
hideMinimap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lifecycle
|
||||
*/
|
||||
@@ -474,6 +518,8 @@ provide(CanvasKey, {
|
||||
@contextmenu="onOpenContextMenu"
|
||||
@viewport-change="onViewportChange"
|
||||
@nodes-change="onNodesChange"
|
||||
@move-start="onPaneMoveStart"
|
||||
@move-end="onPaneMoveEnd"
|
||||
>
|
||||
<template #node-canvas-node="canvasNodeProps">
|
||||
<Node
|
||||
@@ -508,18 +554,23 @@ provide(CanvasKey, {
|
||||
|
||||
<Background data-test-id="canvas-background" pattern-color="#aaa" :gap="GRID_SIZE" />
|
||||
|
||||
<MiniMap
|
||||
data-test-id="canvas-minimap"
|
||||
aria-label="n8n Minimap"
|
||||
:height="120"
|
||||
:width="200"
|
||||
:position="PanelPosition.BottomLeft"
|
||||
pannable
|
||||
zoomable
|
||||
:node-class-name="minimapNodeClassnameFn"
|
||||
mask-color="var(--color-background-base)"
|
||||
:node-border-radius="16"
|
||||
/>
|
||||
<Transition name="minimap">
|
||||
<MiniMap
|
||||
v-show="isMinimapVisible"
|
||||
data-test-id="canvas-minimap"
|
||||
aria-label="n8n Minimap"
|
||||
:height="120"
|
||||
:width="200"
|
||||
:position="PanelPosition.BottomLeft"
|
||||
pannable
|
||||
zoomable
|
||||
:node-class-name="minimapNodeClassnameFn"
|
||||
mask-color="var(--color-background-base)"
|
||||
:node-border-radius="16"
|
||||
@mouseenter="onMinimapMouseEnter"
|
||||
@mouseleave="onMinimapMouseLeave"
|
||||
/>
|
||||
</Transition>
|
||||
|
||||
<CanvasControlButtons
|
||||
data-test-id="canvas-controls"
|
||||
@@ -556,3 +607,15 @@ provide(CanvasKey, {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.minimap-enter-active,
|
||||
.minimap-leave-active {
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.minimap-enter-from,
|
||||
.minimap-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user