0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-26 08:29:42 -05:00

💄 Add cosmetic changes on viewport hooks and actions

This commit is contained in:
Andrey Antukh 2023-06-20 14:04:19 +02:00
parent ea5b153578
commit 23d358aea7
2 changed files with 16 additions and 14 deletions

View file

@ -337,7 +337,7 @@
(defn on-pointer-move [move-stream] (defn on-pointer-move [move-stream]
(let [last-position (mf/use-var nil)] (let [last-position (mf/use-var nil)]
(mf/use-callback (mf/use-fn
(fn [event] (fn [event]
(let [raw-pt (dom/get-client-position event) (let [raw-pt (dom/get-client-position event)
pt (uwvv/point->viewport raw-pt) pt (uwvv/point->viewport raw-pt)
@ -347,6 +347,7 @@
delta (if @last-position delta (if @last-position
(gpt/subtract raw-pt @last-position) (gpt/subtract raw-pt @last-position)
(gpt/point 0 0))] (gpt/point 0 0))]
(rx/push! move-stream pt) (rx/push! move-stream pt)
(reset! last-position raw-pt) (reset! last-position raw-pt)
(st/emit! (ms/->PointerEvent :delta delta (st/emit! (ms/->PointerEvent :delta delta

View file

@ -139,6 +139,7 @@
(fn [point] (fn [point]
(let [zoom (mf/ref-val zoom-ref) (let [zoom (mf/ref-val zoom-ref)
rect (grc/center->rect point (/ 5 zoom) (/ 5 zoom))] rect (grc/center->rect point (/ 5 zoom) (/ 5 zoom))]
(if (mf/ref-val hover-disabled-ref) (if (mf/ref-val hover-disabled-ref)
(rx/of nil) (rx/of nil)
(->> (uw/ask-buffered! (->> (uw/ask-buffered!
@ -152,20 +153,20 @@
(rx/filter some?)))))) (rx/filter some?))))))
over-shapes-stream over-shapes-stream
(mf/use-memo (mf/with-memo [move-stream mod-str]
(fn [] (rx/merge
(rx/merge ;; This stream works to "refresh" the outlines when the control is pressed
;; This stream works to "refresh" the outlines when the control is pressed ;; but the mouse has not been moved from its position.
;; but the mouse has not been moved from its position. (->> mod-str
(->> mod-str (rx/observe-on :async)
(rx/observe-on :async) (rx/map #(deref last-point-ref))
(rx/map #(deref last-point-ref)) (rx/filter some?)
(rx/merge-map query-point)) (rx/merge-map query-point))
(->> move-stream (->> move-stream
(rx/tap #(reset! last-point-ref %)) (rx/tap #(reset! last-point-ref %))
;; When transforming shapes we stop querying the worker ;; When transforming shapes we stop querying the worker
(rx/merge-map query-point)))))] (rx/merge-map query-point))))]
;; Refresh the refs on a value change ;; Refresh the refs on a value change
(mf/use-effect (mf/use-effect