This commit is contained in:
Roman Volosovskyi 2016-06-21 20:13:51 +03:00
parent 8e2c207b2e
commit 2887e1c502
1 changed files with 28 additions and 16 deletions

View File

@ -38,24 +38,36 @@
(defn enough-dy [gesture]
(> (Math/abs (.-dy gesture)) 10))
(defn pan-responder [response-height kb-height orientation]
(drag/create-pan-responder
{:on-move (fn [_ gesture]
(defn on-move [response-height kb-height orientation]
(fn [_ gesture]
(when (enough-dy gesture)
(let [w (react/get-dimensions "window")
;; depending on orientation use height or width of screen
prop (if (= :portrait @orientation)
:height
:width)
;; subtract keyboard height to get "real height" of screen
;; then subtract gesture position to get suggestions height
;; todo maybe it is better to use margin-top instead height
;; it is not obvious
to-value (- (prop w) @kb-height (.-moveY gesture))]
(println to-value )
(anim/start
(anim/spring response-height {:toValue to-value})))))
:on-release (fn [_ gesture]
(anim/spring response-height {:toValue to-value}))))))
(defn on-release [response-height]
(fn [_ gesture]
(when (enough-dy gesture)
(dispatch [:fix-response-height
(.-vy gesture)
;; todo access to "private" property
;; better to find another way...
(.-_value response-height)])))}))
(.-_value response-height)]))))
(defn pan-responder [response-height kb-height orientation]
(drag/create-pan-responder
{:on-move (on-move response-height kb-height orientation)
:on-release (on-release response-height)}))
(defn request-info [response-height]
(let [orientation (subscribe [:get :orientation])