mirror of
https://github.com/penpot/penpot.git
synced 2026-09-11 22:49:30 +00:00
⚡ Coalesce live drag preview state and reduce sidebar churn
This commit is contained in:
parent
55d085117b
commit
5c4d16fc2b
@ -30,6 +30,7 @@
|
|||||||
[app.main.data.workspace.shapes :as dwsh]
|
[app.main.data.workspace.shapes :as dwsh]
|
||||||
[app.main.data.workspace.undo :as dwu]
|
[app.main.data.workspace.undo :as dwu]
|
||||||
[app.main.features :as features]
|
[app.main.features :as features]
|
||||||
|
[app.main.streams :as ms]
|
||||||
[app.render-wasm.api :as wasm.api]
|
[app.render-wasm.api :as wasm.api]
|
||||||
[app.render-wasm.shape :as wasm.shape]
|
[app.render-wasm.shape :as wasm.shape]
|
||||||
[beicon.v2.core :as rx]
|
[beicon.v2.core :as rx]
|
||||||
@ -617,16 +618,16 @@
|
|||||||
(defn set-temporary-selrect
|
(defn set-temporary-selrect
|
||||||
[selrect]
|
[selrect]
|
||||||
(ptk/reify ::set-temporary-selrect
|
(ptk/reify ::set-temporary-selrect
|
||||||
ptk/UpdateEvent
|
ptk/EffectEvent
|
||||||
(update [_ state]
|
(effect [_ _ _]
|
||||||
(assoc state :workspace-selrect selrect))))
|
(rx/push! ms/workspace-selrect selrect))))
|
||||||
|
|
||||||
(defn set-temporary-modifiers
|
(defn set-temporary-modifiers
|
||||||
[modifiers]
|
[modifiers]
|
||||||
(ptk/reify ::set-temporary-modifiers
|
(ptk/reify ::set-temporary-modifiers
|
||||||
ptk/UpdateEvent
|
ptk/EffectEvent
|
||||||
(update [_ state]
|
(effect [_ _ _]
|
||||||
(assoc state :workspace-wasm-modifiers modifiers))))
|
(rx/push! ms/wasm-modifiers modifiers))))
|
||||||
|
|
||||||
(def ^:private xf:map-key (map key))
|
(def ^:private xf:map-key (map key))
|
||||||
|
|
||||||
|
|||||||
@ -138,9 +138,12 @@
|
|||||||
(ptk/reify ::finish-transform
|
(ptk/reify ::finish-transform
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(update state :workspace-local dissoc :transform :duplicate-move-started?))
|
||||||
(update :workspace-local dissoc :transform :duplicate-move-started?)
|
|
||||||
(dissoc :workspace-selrect :workspace-wasm-modifiers)))))
|
ptk/EffectEvent
|
||||||
|
(effect [_ _ _]
|
||||||
|
(rx/push! ms/wasm-modifiers nil)
|
||||||
|
(rx/push! ms/workspace-selrect nil))))
|
||||||
|
|
||||||
;; -- Resize --------------------------------------------------------
|
;; -- Resize --------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,8 @@
|
|||||||
[app.main.data.helpers :as dsh]
|
[app.main.data.helpers :as dsh]
|
||||||
[app.main.data.workspace.tokens.selected-set :as dwts]
|
[app.main.data.workspace.tokens.selected-set :as dwts]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
[app.main.streams :as ms]
|
||||||
|
[beicon.v2.core :as rx]
|
||||||
[okulary.core :as l]))
|
[okulary.core :as l]))
|
||||||
|
|
||||||
;; ---- Global refs
|
;; ---- Global refs
|
||||||
@ -161,7 +163,9 @@
|
|||||||
(l/derived :workspace-tokens st/state))
|
(l/derived :workspace-tokens st/state))
|
||||||
|
|
||||||
(def workspace-selrect
|
(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
|
;; WARNING: Don't use directly from components, this is a proxy to
|
||||||
;; improve performance of selected-shapes and
|
;; improve performance of selected-shapes and
|
||||||
@ -385,7 +389,9 @@
|
|||||||
(l/derived :workspace-wasm-editor-styles st/state))
|
(l/derived :workspace-wasm-editor-styles st/state))
|
||||||
|
|
||||||
(def workspace-wasm-modifiers
|
(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
|
(def ^:private workspace-modifiers-with-objects
|
||||||
(l/derived
|
(l/derived
|
||||||
|
|||||||
@ -22,6 +22,16 @@
|
|||||||
(or ^boolean (kbd/keyboard-event? event)
|
(or ^boolean (kbd/keyboard-event? event)
|
||||||
^boolean (mse/mouse-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
|
;; --- Derived streams
|
||||||
|
|
||||||
(defonce ^:private pointer
|
(defonce ^:private pointer
|
||||||
|
|||||||
@ -73,7 +73,7 @@
|
|||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
(mf/defc shape-options*
|
(mf/defc shape-options*
|
||||||
{::mf/wrap [#(mf/throttle % 100)]
|
{::mf/wrap [#(mf/throttle % 200)]
|
||||||
::mf/private true}
|
::mf/private true}
|
||||||
[{:keys [shapes shapes-with-children selected page-id file-id libraries]}]
|
[{:keys [shapes shapes-with-children selected page-id file-id libraries]}]
|
||||||
(if (= 1 (count selected))
|
(if (= 1 (count selected))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user