                                      (-> x
                                          (min xmax)
                                          (max xmin)))
-                             target-n (bound (+ start-n delta-n) 0 (dec @panel-count))
+                             target-n (bound (+ start-n delta-n) 0 (dec (@state :panel-count)))
                              target-x (* width target-n)]
 
                         (set! (.-scrollLeft (@state :container)) target-x)))

         (.addEventListener js/document "touchstart" touch-start!)
         (swap! state assoc :container (r/dom-node component)))
       :component-will-update
       (fn [this _]
         (reset! panel-count (count (first (r/children this)))))
       :component-will-unmount
       (fn []
         (.removeEventListener js/document "touchend" touch-end!)

           :vertical-align "top" }]]])]))

(defn swipe-view [panel-items panel-view]
  (let [state (atom {:container nil
                     :panel-count (count panel-items)
                     :dragging? false
                     :scroll-x-start nil})

