 (defn hammer-manager [svg]
   (let [manager (js/Hammer.Manager. (.node svg))]
     (.add manager (js/Hammer.Pan.
-                    (js-obj "threshold" 10)))
+                    (js-obj "threshold" 15)))
     (-> manager (.add (js/Hammer.Swipe.
-                        (js-obj "threshold" 10
+                        (js-obj "threshold" 15
                                 "velocity" 0)))
         (.recognizeWith (.get manager "pan")))
     (-> manager (.add (js/Hammer.Pinch.))
         (.recognizeWith (.get manager "pan")))
     (.add manager (js/Hammer.Tap.
-                    (js-obj "threshold" 10)))
+                    (js-obj "threshold" 15)))
     manager))
 
 (defn gesture-observable [manager gesture]

                                           animation-subject
                                           node-tap-subject
                                           link-tap-subject))]
    (sync-graph! @current-state)
    (load-graph "miserables.json"
                (fn [graph]
                  (let [{:keys [nodes links]} graph]
                    (swap-state! current-state assoc :nodes nodes :links links))))
    (move-camera-on-arrow-keys! current-state animation-subject)
    (move-camera-on-pan! gesture-manager current-state animation-subject)
    (move-camera-on-swipe! gesture-manager current-state animation-subject)


(def tick-observable (js/Rx.Observable.interval update-interval-ms))

;; Resize

(defn sync-on-container-size! [current-state selector]
  (let [container (.select d3 selector)
        element (.node container)
        width (.-clientWidth element)
        height (.-clientHeight element)
        svg (:svg @current-state)
        background (.select svg ".background")]
    (-> svg (.attr "width" width) (.attr "height" height))
    (-> background (.attr "width" width) (.attr "height" height))
    (swap-state! current-state assoc :view-size (v/create width height))))

(def resize-observable
  (-> rx-observable (.fromEvent js/window "resize")
      (.map :resize)
      (.debounce resize-delay-ms)))

(defn respond-to-resize! [current-state selector]
  (.subscribe resize-observable
              #(sync-on-container-size! current-state selector)))

;; Animation

(defn animation-subject []
  (js/Rx.BehaviorSubject. :animation-end))

