                        (<= 1.5 t 2) (- 0.5 (- t 1.5))
                        (<= 2 t) 0)))))
 
+(defn view-radius [state pos]
+  (let [{:keys [view-size camera-pos]} state
+        view-center (scalar-multiply view-size 0.5)
+        view-radius (dist view-center)
+        displacement (subtract-vec pos camera-pos)
+        r (dist displacement)]
+    (project-radius r view-radius)))
+
 (defn sync-graph! [state]
   (let [{:keys [svg nodes]} state
-        _view-position (fn [d] (view-position state (:x d) (:y d)))
+        _view-position (fn [d] (view-position state (:pos d)))
         view-x (comp :x _view-position)
         view-y (comp :y _view-position)
-        _view-radius (fn [d] (view-radius state (:x d) (:y d)))]
+        _view-radius (fn [d] (view-radius state (:pos d)))]
     (-> svg
         (.selectAll ".node")
         (.data (apply array nodes))

(defn pan-observable [manager svg]
  (gesture-observable manager svg "panstart panmove"))


(defn pan-deltas-observable [manager svg]
  (-> (pan-observable manager svg)
      (.bufferWithCount 2 1)

        (.merge (-> rx-observable (.fromEvent elem "touchstart")))
        (.map (constantly :scroll-end)))))

(defn dampen [v]
  (let [length (dist v)]
    (vec-with-length v (- length swipe-damping-factor))))

(defn swipe-displacements-observable [manager svg]
  (let [swipes (swipe-observable manager svg)
