 
 (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)

                       child]])) children)))

(defn reagent-render [data children]
  (let [component (reagent.core/current-component)
        sneak (get-sneak data)
        gap (get-gap data)
        pages (get-pages component data children)]

                                                :x x})))

(defn get-current-position [event]
  (.-x (.-contentOffset (.-nativeEvent event))))

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