From 660163c8422a17cb8cd5a11b42f51e15431e63a5 Mon Sep 17 00:00:00 2001 From: Nicholas Kariniemi Date: Wed, 6 Aug 2014 07:18:16 +0300 Subject: [PATCH] Prevent triggering grub edit on pan --- src/cljs/grub/view/app.cljs | 3 ++- src/cljs/grub/view/dom.cljs | 3 +++ src/cljs/grub/view/grub.cljs | 10 ++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/cljs/grub/view/app.cljs b/src/cljs/grub/view/app.cljs index a317e40..2fdf9b9 100644 --- a/src/cljs/grub/view/app.cljs +++ b/src/cljs/grub/view/app.cljs @@ -22,7 +22,8 @@ om/IWillMount (will-mount [_] (let [>events (om/get-shared owner :>events)] - (dom/on-document-mousedown #(put! >events {:type :body-mousedown :event %})))))) + (dom/on-document-mousedown #(put! >events {:type :body-mousedown :event %})) + (dom/on-window-scroll #(put! >events {:type :body-scroll :event %})))))) (defn render-app [state] (let [grub-add (chan) diff --git a/src/cljs/grub/view/dom.cljs b/src/cljs/grub/view/dom.cljs index 595bc4a..e3cb4f8 100644 --- a/src/cljs/grub/view/dom.cljs +++ b/src/cljs/grub/view/dom.cljs @@ -13,5 +13,8 @@ (defn on-document-mousedown [f] (.addEventListener js/document "mousedown" f)) +(defn on-window-scroll [f] + (.addEventListener js/window "scroll" f)) + (defn event-val [event] (.. event -target -value)) diff --git a/src/cljs/grub/view/grub.cljs b/src/cljs/grub/view/grub.cljs index 81cad4c..ee6e0a0 100644 --- a/src/cljs/grub/view/grub.cljs +++ b/src/cljs/grub/view/grub.cljs @@ -37,7 +37,8 @@ :mouse-out :waiting :touch-cancel :waiting :touch-end :waiting - :timeout :editing} + :timeout :editing + :scroll :waiting} :editing {:enter :waiting :body-mousedown :waiting}}) @@ -95,7 +96,12 @@ (let [