mirror of
https://github.com/penpot/penpot.git
synced 2025-05-25 00:46:11 +02:00
Move some logic from events to state management.
This commit is contained in:
parent
48af590bd8
commit
25d4297df5
2 changed files with 12 additions and 8 deletions
|
@ -338,19 +338,13 @@
|
||||||
(defn drop-shape
|
(defn drop-shape
|
||||||
"Event used in drag and drop for transfer shape
|
"Event used in drag and drop for transfer shape
|
||||||
from one position to an other."
|
from one position to an other."
|
||||||
[sid tid type]
|
[sid tid loc]
|
||||||
{:pre [(not (nil? tid))
|
{:pre [(not (nil? tid))
|
||||||
(not (nil? sid))]}
|
(not (nil? sid))]}
|
||||||
(reify
|
(reify
|
||||||
rs/UpdateEvent
|
rs/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(-apply-update [_ state]
|
||||||
(if (= tid sid)
|
(stsh/drop-shape state tid sid loc))))
|
||||||
state
|
|
||||||
(case type
|
|
||||||
:inside (stsh/drop-inside state tid sid)
|
|
||||||
:before (stsh/drop-before state tid sid)
|
|
||||||
:after (stsh/drop-after state tid sid)
|
|
||||||
(throw (ex-info "Invalid data" {})))))))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Events (for selected)
|
;; Events (for selected)
|
||||||
|
|
|
@ -117,3 +117,13 @@
|
||||||
(assoc-in $ [:shapes-by-id tid :items] (conj shapes sid))
|
(assoc-in $ [:shapes-by-id tid :items] (conj shapes sid))
|
||||||
(update-in $ [:shapes-by-id sid] assoc :group tid))
|
(update-in $ [:shapes-by-id sid] assoc :group tid))
|
||||||
state)))
|
state)))
|
||||||
|
|
||||||
|
(defn drop-shape
|
||||||
|
[state tid sid loc]
|
||||||
|
(if (= tid sid)
|
||||||
|
state
|
||||||
|
(case loc
|
||||||
|
:inside (drop-inside state tid sid)
|
||||||
|
:before (drop-before state tid sid)
|
||||||
|
:after (drop-after state tid sid)
|
||||||
|
(throw (ex-info "Invalid data" {})))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue