 
 (defn get-page-width [data]
   (get data :pageWidth (:pageWidth defaults)))
+
+(defn get-scroll-threshold [data]
+  (get data :scrollThreshold (:scrollThreshold defaults)))
 
 (defn calculate-gap [component props]
   (let [prop-page-width (get-page-width props)

                                                :x x})))

(defn get-current-position [event]
  (+ (.-x (.-contentOffset (.-nativeEvent event))) (quot (page-width) 2)))

(defn on-scroll-end [event component]
  (let [props (reagent.core/props component)
        state (reagent.core/state component)
        prop-page-width (get-page-width props)
        sneak (get-sneak props)
        gap (get-gap state)
        page-offset (+ prop-page-width gap)
        current-position (get-current-position event)
        current-page (quot current-position page-offset)
        ]
    (log/debug "on-scroll-end: prop-page-width=" prop-page-width
               "; sneak=" sneak "; gap=" gap "; page-offset=" page-offset
               "; current-position=" current-position
               "; current-page=" current-page)
    (scroll-to component (* current-page page-offset) 0)
    (reagent.core/set-state component {:activePage current-page})
    (when (:onPageChange props)

                 :bounces false
                 :decelerationRate 0.9
                 :horizontal true
                 :onScrollBeginDrag (fn [event]
                                      (let []
                                        (reset! starting-position (get-current-position event))))
                 :onScrollEndDrag (fn [event] (on-scroll-end event component @starting-position))
                 :showsHorizontalScrollIndicator false
                 :ref (fn [c] (set! (.-scrollView component) c))
                 }
