mirror of
https://github.com/penpot/penpot.git
synced 2025-01-25 07:58:49 -05:00
🐛 Fix problem with move+alt
This commit is contained in:
parent
f9082e18e2
commit
68e3d53cb7
5 changed files with 28 additions and 19 deletions
|
@ -428,14 +428,14 @@
|
|||
delta (gpt/subtract new-pos (gpt/point obj))]
|
||||
delta))))
|
||||
|
||||
(def duplicate-selected
|
||||
(defn duplicate-selected [move-delta?]
|
||||
(ptk/reify ::duplicate-selected
|
||||
ptk/WatchEvent
|
||||
(watch [it state _]
|
||||
(let [page-id (:current-page-id state)
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
selected (wsh/lookup-selected state)
|
||||
delta (if (= (count selected) 1)
|
||||
delta (if (and move-delta? (= (count selected) 1))
|
||||
(let [obj (get objects (first selected))]
|
||||
(calc-duplicate-delta obj state objects))
|
||||
(gpt/point 0 0))
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
|
||||
:duplicate {:tooltip (ds/meta "D")
|
||||
:command (ds/c-mod "d")
|
||||
:fn #(st/emit! dw/duplicate-selected)}
|
||||
:fn #(st/emit! (dw/duplicate-selected true))}
|
||||
|
||||
:undo {:tooltip (ds/meta "Z")
|
||||
:command (ds/c-mod "z")
|
||||
|
|
|
@ -505,7 +505,7 @@
|
|||
(if alt?
|
||||
;; When alt is down we start a duplicate+move
|
||||
(rx/of (start-move-duplicate initial)
|
||||
dws/duplicate-selected)
|
||||
(dws/duplicate-selected false))
|
||||
;; Otherwise just plain old move
|
||||
(rx/of (start-move initial selected)))))))))))
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
|
||||
current-file-id (mf/use-ctx ctx/current-file-id)
|
||||
|
||||
do-duplicate (st/emitf dw/duplicate-selected)
|
||||
do-duplicate (st/emitf (dw/duplicate-selected false))
|
||||
do-delete (st/emitf dw/delete-selected)
|
||||
do-copy (st/emitf (dw/copy-selected))
|
||||
do-cut (st/emitf (dw/copy-selected) dw/delete-selected)
|
||||
|
|
|
@ -117,10 +117,16 @@
|
|||
over-shapes-stream
|
||||
(mf/use-memo
|
||||
(fn []
|
||||
(->> move-stream
|
||||
;; When transforming shapes we stop querying the worker
|
||||
(rx/filter #(not (some? (mf/ref-val transform-ref))))
|
||||
(rx/switch-map query-point))))]
|
||||
(rx/merge
|
||||
(->> move-stream
|
||||
;; When transforming shapes we stop querying the worker
|
||||
(rx/filter #(not (some? (mf/ref-val transform-ref))))
|
||||
(rx/switch-map query-point))
|
||||
|
||||
(->> move-stream
|
||||
;; When transforming shapes we stop querying the worker
|
||||
(rx/filter #(some? (mf/ref-val transform-ref)))
|
||||
(rx/map (constantly nil))))))]
|
||||
|
||||
;; Refresh the refs on a value change
|
||||
(mf/use-effect
|
||||
|
@ -147,19 +153,22 @@
|
|||
over-shapes-stream
|
||||
(mf/deps page-id objects @ctrl?)
|
||||
(fn [ids]
|
||||
(let [selected (mf/ref-val selected-ref)
|
||||
remove-id? (into #{} (mapcat #(cp/get-parents % objects)) selected)
|
||||
|
||||
is-group?
|
||||
(let [is-group?
|
||||
(fn [id]
|
||||
(contains? #{:group :bool} (get-in objects [id :type])))
|
||||
|
||||
remove-id?
|
||||
(if @ctrl?
|
||||
(d/concat remove-id? (filterv is-group? ids))
|
||||
remove-id?)
|
||||
ids (->> ids (filterv (comp not remove-id?)))]
|
||||
(reset! hover (get objects (first ids)))
|
||||
selected (mf/ref-val selected-ref)
|
||||
|
||||
remove-xfm (mapcat #(cp/get-parents % objects))
|
||||
remove-id? (cond-> (into #{} remove-xfm selected)
|
||||
@ctrl?
|
||||
(d/concat (filterv is-group? ids)))
|
||||
|
||||
ids (->> ids (filterv (comp not remove-id?)))
|
||||
|
||||
hover-shape (get objects (first ids))]
|
||||
|
||||
(reset! hover hover-shape)
|
||||
(reset! hover-ids ids))))))
|
||||
|
||||
(defn setup-viewport-modifiers [modifiers selected objects render-ref]
|
||||
|
|
Loading…
Add table
Reference in a new issue