From 4a22c4a98386f64346896a4a021126a4d6ea5236 Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Thu, 22 Dec 2016 18:04:41 +0200 Subject: [PATCH] fix #577 --- src/status_im/components/main_tabs.cljs | 32 ++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/status_im/components/main_tabs.cljs b/src/status_im/components/main_tabs.cljs index e075308ada..6897002597 100644 --- a/src/status_im/components/main_tabs.cljs +++ b/src/status_im/components/main_tabs.cljs @@ -1,6 +1,7 @@ (ns status-im.components.main-tabs (:require-macros [reagent.ratom :refer [reaction]] - [status-im.utils.views :refer [defview]]) + [status-im.utils.views :refer [defview]] + [cljs.core.async.macros :as am]) (:require [re-frame.core :refer [subscribe dispatch dispatch-sync]] [reagent.core :as r] [status-im.components.react :refer [view @@ -21,7 +22,7 @@ [status-im.components.tabs.styles :as st] [status-im.components.styles :as common-st] [status-im.i18n :refer [label]] - [taoensso.timbre :as log])) + [cljs.core.async :as a])) (def tab-list [{:view-id :chat-list @@ -57,7 +58,7 @@ (dispatch [:on-navigated-to-tab])))))))))) (def tab->index {:chat-list 0 - :discover 1 + :discover 1 :contact-list 2}) (def index->tab (clojure.set/map-invert tab->index)) @@ -70,28 +71,43 @@ n (get-tab-index view-id)] (- n p))) -(defn on-scroll-end [swiped? dragging?] +(defn on-scroll-end [swiped? dragging? scroll-ended] (fn [_ state] + (a/put! scroll-ended true) (when @dragging? (reset! dragging? false) (let [{:strs [index]} (js->clj state)] (reset! swiped? true) (dispatch [:navigate-to-tab (index->tab index)]))))) +(defn start-scrolling-loop + "Loop that synchronizes tabs scrolling to avoid an inconsistent state." + [scroll-start scroll-ended] + (am/go-loop [[swiper to] (a/