From 1212eb9097563ff144cdbb83a27d45b6a10f5908 Mon Sep 17 00:00:00 2001 From: Mutasem Date: Mon, 1 Nov 2021 16:11:37 +0100 Subject: [PATCH] refactor --- packages/editor-ui/src/views/NodeView.vue | 24 +++---------------- packages/editor-ui/src/views/canvasHelpers.ts | 19 +++++++++++++++ 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/packages/editor-ui/src/views/NodeView.vue b/packages/editor-ui/src/views/NodeView.vue index c3deb12bfb..c86a6880e1 100644 --- a/packages/editor-ui/src/views/NodeView.vue +++ b/packages/editor-ui/src/views/NodeView.vue @@ -1363,24 +1363,6 @@ export default mixins( // only one set of visible actions should be visible at the same time let activeConnection: null | Connection = null; - const hideActions = (connection: Connection | null) => { - if (connection) { - CanvasHelpers.hideOverlay(connection, CanvasHelpers.OVERLAY_CONNECTION_ACTIONS_ID); - CanvasHelpers.showOrHideItemsLabel(connection); - CanvasHelpers.showOrHideMidpointArrow(connection); - } - }; - - const showActions = (connection: Connection | null) => { - if (connection) { - CanvasHelpers.showOverlay(connection, CanvasHelpers.OVERLAY_CONNECTION_ACTIONS_ID); - CanvasHelpers.hideOverlay(connection, CanvasHelpers.OVERLAY_RUN_ITEMS_ID); - if (!connection.getOverlay(CanvasHelpers.OVERLAY_RUN_ITEMS_ID)) { - CanvasHelpers.hideOverlay(connection, CanvasHelpers.OVERLAY_MIDPOINT_ARROW_ID); - } - } - }; - this.instance.bind('connection', (info: OnConnectionBindInfo) => { const sourceInfo = info.sourceEndpoint.getParameters(); const targetInfo = info.targetEndpoint.getParameters(); @@ -1422,12 +1404,12 @@ export default mixins( return; } - hideActions(activeConnection); + CanvasHelpers.hideConnectionActions(activeConnection); enterTimer = setTimeout(() => { enterTimer = undefined; activeConnection = info.connection; - showActions(info.connection); + CanvasHelpers.showConnectionActions(info.connection); }, 150); }); @@ -1449,7 +1431,7 @@ export default mixins( exitTimer = undefined; if (activeConnection === info.connection) { - hideActions(activeConnection); + CanvasHelpers.hideConnectionActions(activeConnection); activeConnection = null; } }, 500); diff --git a/packages/editor-ui/src/views/canvasHelpers.ts b/packages/editor-ui/src/views/canvasHelpers.ts index 6acb0753e2..6ff0dc69d4 100644 --- a/packages/editor-ui/src/views/canvasHelpers.ts +++ b/packages/editor-ui/src/views/canvasHelpers.ts @@ -343,3 +343,22 @@ export const getBackgroundStyles = (scale: number, offsetPosition: XYPosition) = } return styles; }; + +export const hideConnectionActions = (connection: Connection | null) => { + if (connection) { + hideOverlay(connection, OVERLAY_CONNECTION_ACTIONS_ID); + showOrHideItemsLabel(connection); + showOrHideMidpointArrow(connection); + } +}; + +export const showConectionActions = (connection: Connection | null) => { + if (connection) { + showOverlay(connection, OVERLAY_CONNECTION_ACTIONS_ID); + hideOverlay(connection, OVERLAY_RUN_ITEMS_ID); + if (!connection.getOverlay(OVERLAY_RUN_ITEMS_ID)) { + hideOverlay(connection, OVERLAY_MIDPOINT_ARROW_ID); + } + } +}; +