mirror of
https://github.com/penpot/penpot.git
synced 2026-05-07 00:58:48 +00:00
⚡ Coalesce live drag preview state and reduce sidebar churn
This commit is contained in:
parent
14a0660352
commit
9230091492
@ -30,6 +30,7 @@
|
||||
[app.main.data.workspace.shapes :as dwsh]
|
||||
[app.main.data.workspace.undo :as dwu]
|
||||
[app.main.features :as features]
|
||||
[app.main.streams :as ms]
|
||||
[app.render-wasm.api :as wasm.api]
|
||||
[app.render-wasm.shape :as wasm.shape]
|
||||
[beicon.v2.core :as rx]
|
||||
@ -617,16 +618,16 @@
|
||||
(defn set-temporary-selrect
|
||||
[selrect]
|
||||
(ptk/reify ::set-temporary-selrect
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc state :workspace-selrect selrect))))
|
||||
ptk/EffectEvent
|
||||
(effect [_ _ _]
|
||||
(rx/push! ms/workspace-selrect selrect))))
|
||||
|
||||
(defn set-temporary-modifiers
|
||||
[modifiers]
|
||||
(ptk/reify ::set-temporary-modifiers
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc state :workspace-wasm-modifiers modifiers))))
|
||||
ptk/EffectEvent
|
||||
(effect [_ _ _]
|
||||
(rx/push! ms/wasm-modifiers modifiers))))
|
||||
|
||||
(def ^:private xf:map-key (map key))
|
||||
|
||||
|
||||
@ -138,9 +138,12 @@
|
||||
(ptk/reify ::finish-transform
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(-> state
|
||||
(update :workspace-local dissoc :transform :duplicate-move-started?)
|
||||
(dissoc :workspace-selrect :workspace-wasm-modifiers)))))
|
||||
(update state :workspace-local dissoc :transform :duplicate-move-started?))
|
||||
|
||||
ptk/EffectEvent
|
||||
(effect [_ _ _]
|
||||
(rx/push! ms/wasm-modifiers nil)
|
||||
(rx/push! ms/workspace-selrect nil))))
|
||||
|
||||
;; -- Resize --------------------------------------------------------
|
||||
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
[app.main.data.helpers :as dsh]
|
||||
[app.main.data.workspace.tokens.selected-set :as dwts]
|
||||
[app.main.store :as st]
|
||||
[app.main.streams :as ms]
|
||||
[beicon.v2.core :as rx]
|
||||
[okulary.core :as l]))
|
||||
|
||||
;; ---- Global refs
|
||||
@ -161,7 +163,9 @@
|
||||
(l/derived :workspace-tokens st/state))
|
||||
|
||||
(def workspace-selrect
|
||||
(l/derived :workspace-selrect st/state))
|
||||
(let [a (atom nil)]
|
||||
(rx/sub! ms/workspace-selrect #(reset! a %))
|
||||
a))
|
||||
|
||||
;; WARNING: Don't use directly from components, this is a proxy to
|
||||
;; improve performance of selected-shapes and
|
||||
@ -385,7 +389,9 @@
|
||||
(l/derived :workspace-wasm-editor-styles st/state))
|
||||
|
||||
(def workspace-wasm-modifiers
|
||||
(l/derived :workspace-wasm-modifiers st/state))
|
||||
(let [a (atom nil)]
|
||||
(rx/sub! ms/wasm-modifiers #(reset! a %))
|
||||
a))
|
||||
|
||||
(def ^:private workspace-modifiers-with-objects
|
||||
(l/derived
|
||||
|
||||
@ -22,6 +22,16 @@
|
||||
(or ^boolean (kbd/keyboard-event? event)
|
||||
^boolean (mse/mouse-event? event)))
|
||||
|
||||
;; Live preview state for an interactive transform. Pushed by drag
|
||||
;; events at the cadence set by upstream `rx/sample` (see
|
||||
;; `transforms.cljs`); subscribed via plain atoms in `app.main.refs` so
|
||||
;; updates bypass the Redux store and don't re-run unrelated lenses.
|
||||
(defonce wasm-modifiers
|
||||
(rx/behavior-subject nil))
|
||||
|
||||
(defonce workspace-selrect
|
||||
(rx/behavior-subject nil))
|
||||
|
||||
;; --- Derived streams
|
||||
|
||||
(defonce ^:private pointer
|
||||
|
||||
@ -73,7 +73,7 @@
|
||||
nil)))
|
||||
|
||||
(mf/defc shape-options*
|
||||
{::mf/wrap [#(mf/throttle % 100)]
|
||||
{::mf/wrap [#(mf/throttle % 200)]
|
||||
::mf/private true}
|
||||
[{:keys [shapes shapes-with-children selected page-id file-id libraries]}]
|
||||
(if (= 1 (count selected))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user