From 23d358aea7a8c8bf8a1fcac3688fb365ff9e449b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 20 Jun 2023 14:04:19 +0200 Subject: [PATCH] :lipstick: Add cosmetic changes on viewport hooks and actions --- .../main/ui/workspace/viewport/actions.cljs | 3 ++- .../app/main/ui/workspace/viewport/hooks.cljs | 27 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/viewport/actions.cljs b/frontend/src/app/main/ui/workspace/viewport/actions.cljs index 19fca8fb0..dc70ebd6f 100644 --- a/frontend/src/app/main/ui/workspace/viewport/actions.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/actions.cljs @@ -337,7 +337,7 @@ (defn on-pointer-move [move-stream] (let [last-position (mf/use-var nil)] - (mf/use-callback + (mf/use-fn (fn [event] (let [raw-pt (dom/get-client-position event) pt (uwvv/point->viewport raw-pt) @@ -347,6 +347,7 @@ delta (if @last-position (gpt/subtract raw-pt @last-position) (gpt/point 0 0))] + (rx/push! move-stream pt) (reset! last-position raw-pt) (st/emit! (ms/->PointerEvent :delta delta diff --git a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs index fd8588835..2ae9b2cea 100644 --- a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs @@ -139,6 +139,7 @@ (fn [point] (let [zoom (mf/ref-val zoom-ref) rect (grc/center->rect point (/ 5 zoom) (/ 5 zoom))] + (if (mf/ref-val hover-disabled-ref) (rx/of nil) (->> (uw/ask-buffered! @@ -152,20 +153,20 @@ (rx/filter some?)))))) over-shapes-stream - (mf/use-memo - (fn [] - (rx/merge - ;; This stream works to "refresh" the outlines when the control is pressed - ;; but the mouse has not been moved from its position. - (->> mod-str - (rx/observe-on :async) - (rx/map #(deref last-point-ref)) - (rx/merge-map query-point)) + (mf/with-memo [move-stream mod-str] + (rx/merge + ;; This stream works to "refresh" the outlines when the control is pressed + ;; but the mouse has not been moved from its position. + (->> mod-str + (rx/observe-on :async) + (rx/map #(deref last-point-ref)) + (rx/filter some?) + (rx/merge-map query-point)) - (->> move-stream - (rx/tap #(reset! last-point-ref %)) - ;; When transforming shapes we stop querying the worker - (rx/merge-map query-point)))))] + (->> move-stream + (rx/tap #(reset! last-point-ref %)) + ;; When transforming shapes we stop querying the worker + (rx/merge-map query-point))))] ;; Refresh the refs on a value change (mf/use-effect