 (defn hammer-manager [svg]
   (let [manager (js/Hammer.Manager. (.node svg))]
     (.add manager (js/Hammer.Pan.))
+    (-> manager (.add (js/Hammer.Swipe.))
+        (.recognizeWith (.get manager "pan")))
     manager))
 
-(defn pan-observable [svg]
-  (let [manager (hammer-manager svg)]
-    (.create
-      rx-observable
-      (fn [observer]
-        (.on manager "panstart panmove"
-             (fn [e] (.onNext observer e)))))))
-
-(defn pan-deltas-observable [svg]
-  (-> (pan-observable svg)
+(defn gesture-observable [manager svg gesture]
+  (.create rx-observable
+           (fn [observer] (.on manager gesture #(.onNext observer %)))))
+
+;; Gestures - pan
+
+(defn pan-observable [manager svg]
+  (gesture-observable manager svg "panstart panmove"))
+
+
+(defn pan-deltas-observable [manager svg]
+  (-> (pan-observable manager svg)
       (.bufferWithCount 2 1)
       (.map (fn [es] (let [[e1 e2] es
                            e1-center (.-center e1)

  (-> arrow-keys-observable
      (.flatMapLatest (fn [arrows] (if (empty? arrows)
                                     (.empty rx-observable)
                                     (-> rx-observable (.interval 15) (.map (constantly arrows))))))
      (.subscribe
        (fn [arrows]
          (let [dx (+ (if (arrows :left) -10 0) (if (arrows :right) 10 0))


(def world-width 1280)
(def world-height 800)
(def update-interval-ms 15)
(def swipe-damping-factor 1)

;; SVG setup

