          (.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)))))
+       (fn [this new-args]
+         (swap! state assoc :panel-count (count (second new-args))))
        :component-will-unmount
        (fn []
          (.removeEventListener js/document "touchend" touch-end!)

                                     (-> x
                                         (min xmax)
                                         (max xmin)))
                             target-n (bound (+ start-n delta-n) 0 (dec @panel-count))
                             target-x (* width target-n)]

                        (set! (.-scrollLeft (@state :container)) target-x)))

           :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})

