From 6fd8ec26cbca979245cacd41301acf2541eb810d Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Mon, 2 Jan 2017 15:28:35 +0200 Subject: [PATCH] fix #600 --- src/status_im/components/main_tabs.cljs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/status_im/components/main_tabs.cljs b/src/status_im/components/main_tabs.cljs index 6897002597..bb5564e0d4 100644 --- a/src/status_im/components/main_tabs.cljs +++ b/src/status_im/components/main_tabs.cljs @@ -71,23 +71,28 @@ n (get-tab-index view-id)] (- n p))) -(defn on-scroll-end [swiped? dragging? scroll-ended] +(defonce scrolling? (atom false)) + +(defn on-scroll-end [swiped? scroll-ended view-id] (fn [_ state] - (a/put! scroll-ended true) - (when @dragging? - (reset! dragging? false) - (let [{:strs [index]} (js->clj state)] + (when @scrolling? + (a/put! scroll-ended true)) + (let [{:strs [index]} (js->clj state) + new-view-id (index->tab index)] + (when-not (= view-id new-view-id) (reset! swiped? true) - (dispatch [:navigate-to-tab (index->tab index)]))))) + (dispatch [:navigate-to-tab new-view-id]))))) (defn start-scrolling-loop "Loop that synchronizes tabs scrolling to avoid an inconsistent state." [scroll-start scroll-ended] (am/go-loop [[swiper to] (a/