Browse Source

disable node click while dragging

AykutSarac 2 năm trước cách đây
mục cha
commit
920c8ff440
1 tập tin đã thay đổi với 10 bổ sung0 xóa
  1. 10 0
      src/components/Graph/index.tsx

+ 10 - 0
src/components/Graph/index.tsx

@@ -32,6 +32,10 @@ const StyledEditorWrapper = styled.div<{ isWidget: boolean }>`
     cursor: move;
   }
 
+  .dragging {
+    pointer-events: none;
+  }
+
   rect {
     fill: ${({ theme }) => theme.BACKGROUND_NODE};
   }
@@ -101,6 +105,12 @@ const MemoizedGraph = React.memo(function Layout({
         zoomAnimation={{ animationType: "linear" }}
         doubleClick={{ disabled: true }}
         onInit={onInit}
+        onPanning={(ref) =>
+          ref.instance.wrapperComponent?.classList.add("dragging")
+        }
+        onPanningStop={(ref) =>
+          ref.instance.wrapperComponent?.classList.remove("dragging")
+        }
       >
         <TransformComponent
           wrapperStyle={{