Browse Source

chore: bump pixi-graph-fork

Tienson Qin 4 years ago
parent
commit
a58de3da97
4 changed files with 16 additions and 16 deletions
  1. 1 1
      package.json
  2. 4 4
      src/main/frontend/components/page.cljs
  3. 7 7
      src/main/frontend/extensions/graph.cljs
  4. 4 4
      yarn.lock

+ 1 - 1
package.json

@@ -83,7 +83,7 @@
         "jszip": "^3.5.0",
         "jszip": "^3.5.0",
         "mldoc": "0.8.8",
         "mldoc": "0.8.8",
         "path": "^0.12.7",
         "path": "^0.12.7",
-        "pixi-graph-fork": "^0.1.0",
+        "pixi-graph-fork": "^0.1.1",
         "posthog-js": "^1.10.2",
         "posthog-js": "^1.10.2",
         "react": "^17.0.2",
         "react": "^17.0.2",
         "react-dom": "^17.0.2",
         "react-dom": "^17.0.2",

+ 4 - 4
src/main/frontend/components/page.cljs

@@ -575,13 +575,13 @@
 
 
 (defonce last-node-position (atom nil))
 (defonce last-node-position (atom nil))
 (defn- graph-register-handlers
 (defn- graph-register-handlers
-  [graph focus-nodes n-hops]
+  [graph focus-nodes n-hops dark?]
   (.on graph "nodeClick"
   (.on graph "nodeClick"
        (fn [event node]
        (fn [event node]
          (let [x (.-x event)
          (let [x (.-x event)
                y (.-y event)
                y (.-y event)
                drag? (not= [node x y] @last-node-position)]
                drag? (not= [node x y] @last-node-position)]
-           (graph/on-click-handler graph node event focus-nodes n-hops drag?))))
+           (graph/on-click-handler graph node event focus-nodes n-hops drag? dark?))))
   (.on graph "nodeMousedown"
   (.on graph "nodeMousedown"
        (fn [event node]
        (fn [event node]
          (reset! last-node-position [node (.-x event) (.-y event)]))))
          (reset! last-node-position [node (.-x event) (.-y event)]))))
@@ -613,7 +613,7 @@
                         :dark? dark?
                         :dark? dark?
                         :register-handlers-fn
                         :register-handlers-fn
                         (fn [graph]
                         (fn [graph]
-                          (graph-register-handlers graph *focus-nodes *n-hops))
+                          (graph-register-handlers graph *focus-nodes *n-hops dark?))
                         :reset? reset?})
                         :reset? reset?})
        (graph-filters graph settings n-hops)])))
        (graph-filters graph settings n-hops)])))
 
 
@@ -667,7 +667,7 @@
                         :dark? dark?
                         :dark? dark?
                         :register-handlers-fn
                         :register-handlers-fn
                         (fn [graph]
                         (fn [graph]
-                          (graph-register-handlers graph (atom nil) (atom nil)))})])))
+                          (graph-register-handlers graph (atom nil) (atom nil) dark?))})])))
 
 
 (rum/defc all-pages < rum/reactive
 (rum/defc all-pages < rum/reactive
   ;; {:did-mount (fn [state]
   ;; {:did-mount (fn [state]

+ 7 - 7
src/main/frontend/extensions/graph.cljs

@@ -24,7 +24,7 @@
                                         :color "#6366F1"}})))
                                         :color "#6366F1"}})))
 
 
 (defn- highlight-neighbours!
 (defn- highlight-neighbours!
-  [^js graph node focus-nodes]
+  [^js graph node focus-nodes dark?]
   (.forEachNeighbor
   (.forEachNeighbor
    (.-graph graph) node
    (.-graph graph) node
    (fn [node attributes]
    (fn [node attributes]
@@ -37,16 +37,16 @@
          (.resetNodeStyle graph node (bean/->js attributes)))))))
          (.resetNodeStyle graph node (bean/->js attributes)))))))
 
 
 (defn- highlight-edges!
 (defn- highlight-edges!
-  [^js graph node]
+  [^js graph node dark?]
   (.forEachEdge
   (.forEachEdge
    (.-graph graph) node
    (.-graph graph) node
    (fn [edge attributes]
    (fn [edge attributes]
      (.resetEdgeStyle graph edge (bean/->js {:width 1
      (.resetEdgeStyle graph edge (bean/->js {:width 1
-                                             :color "#A5B4FC"})))))
+                                             :color (if dark? "#999" "#A5B4FC")})))))
 
 
-(defn on-click-handler [graph node event *focus-nodes *n-hops drag?]
+(defn on-click-handler [graph node event *focus-nodes *n-hops drag? dark?]
   ;; shift+click to select the page
   ;; shift+click to select the page
-  (if (gobj/get event "shiftKey")
+  (if (or (gobj/get event "shiftKey") drag?)
     (let [page-name (string/lower-case node)]
     (let [page-name (string/lower-case node)]
       (when-not @*n-hops
       (when-not @*n-hops
         ;; Don't trigger re-render
         ;; Don't trigger re-render
@@ -57,8 +57,8 @@
       (let [node-attributes (-> (.getNodeAttributes (.-graph graph) node)
       (let [node-attributes (-> (.getNodeAttributes (.-graph graph) node)
                                 (bean/->clj))]
                                 (bean/->clj))]
         (.setNodeAttribute (.-graph graph) node "parent" "ls-selected-nodes"))
         (.setNodeAttribute (.-graph graph) node "parent" "ls-selected-nodes"))
-      (highlight-neighbours! graph node (set @*focus-nodes))
-      (highlight-edges! graph node))
+      (highlight-neighbours! graph node (set @*focus-nodes) dark?)
+      (highlight-edges! graph node dark?))
     (when-not drag?
     (when-not drag?
       (let [page-name (string/lower-case node)]
       (let [page-name (string/lower-case node)]
         (route-handler/redirect! {:to :page
         (route-handler/redirect! {:to :page

+ 4 - 4
yarn.lock

@@ -6775,10 +6775,10 @@ pinkie@^2.0.0:
   resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz"
   resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz"
   integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA=
   integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA=
 
 
-pixi-graph-fork@^0.1.0:
-  version "0.1.0"
-  resolved "https://registry.yarnpkg.com/pixi-graph-fork/-/pixi-graph-fork-0.1.0.tgz#98c54f6681398689cfa880fd8fac313d0ffbe121"
-  integrity sha512-3kuj8Z/Xs7w2FfiOQPqAmQQeHjqk36bLZ5n3t6vyEeCBcdeWc5EqA90+FDjzmTWKmXRsjRLU1NaOeDcSeJXDPA==
+pixi-graph-fork@^0.1.1:
+  version "0.1.1"
+  resolved "https://registry.yarnpkg.com/pixi-graph-fork/-/pixi-graph-fork-0.1.1.tgz#d2bf6c2a4f3efb0516bd7072bf7fceddcfaf7a24"
+  integrity sha512-nP1Uc4NP9r551kxWIm6L5o57WdOUcQ91s3mUAMcWs7qbB2vsCDYnfS17uTiDYqn2w1XyvJdVrJTmpChrpEM07w==
   dependencies:
   dependencies:
     "@pixi-essentials/cull" "^1.1.0"
     "@pixi-essentials/cull" "^1.1.0"
     "@pixi/app" "^6.0.2"
     "@pixi/app" "^6.0.2"