From 977e29f4c349cf20100675725f06000e3582519b Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Tue, 21 Jun 2016 20:13:51 +0300 Subject: [PATCH] comments Former-commit-id: 2887e1c5027f3aa733f4ab60088e6d962b2b2c98 --- src/status_im/chat/views/response.cljs | 44 ++++++++++++++++---------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/src/status_im/chat/views/response.cljs b/src/status_im/chat/views/response.cljs index c9d4870c78..56382052c8 100644 --- a/src/status_im/chat/views/response.cljs +++ b/src/status_im/chat/views/response.cljs @@ -38,24 +38,36 @@ (defn enough-dy [gesture] (> (Math/abs (.-dy gesture)) 10)) +(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})))))) + +(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)])))) + (defn pan-responder [response-height kb-height orientation] (drag/create-pan-responder - {:on-move (fn [_ gesture] - (when (enough-dy gesture) - (let [w (react/get-dimensions "window") - prop (if (= :portrait @orientation) - :height - :width) - to-value (- (prop w) @kb-height (.-moveY gesture))] - (anim/start - (anim/spring response-height {:toValue to-value}))))) - :on-release (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)])))})) + {: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])