Ver código fonte

fix: add drag threshold

situ2001 2 anos atrás
pai
commit
35124d5ffb
1 arquivos alterados com 5 adições e 1 exclusões
  1. 5 1
      src/main/frontend/components/page.cljs

+ 5 - 1
src/main/frontend/components/page.cljs

@@ -666,7 +666,11 @@
        (fn [event node]
          (let [x (.-x event)
                y (.-y event)
-               drag? (not= [node x y] @last-node-position)]
+               drag? (not (let [[last-node last-x last-y] @last-node-position
+                                threshold 5]
+                            (and (= node last-node)
+                                 (<= (abs (- x last-x)) threshold)
+                                 (<= (abs (- y last-y)) threshold))))]
            (graph/on-click-handler graph node event focus-nodes n-hops drag? dark?))))
   (.on graph "nodeMousedown"
        (fn [event node]