mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05: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
|
||||
"Event used in drag and drop for transfer shape
|
||||
from one position to an other."
|
||||
[sid tid type]
|
||||
[sid tid loc]
|
||||
{:pre [(not (nil? tid))
|
||||
(not (nil? sid))]}
|
||||
(reify
|
||||
rs/UpdateEvent
|
||||
(-apply-update [_ state]
|
||||
(if (= tid sid)
|
||||
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" {})))))))
|
||||
(stsh/drop-shape state tid sid loc))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Events (for selected)
|
||||
|
|
|
@ -117,3 +117,13 @@
|
|||
(assoc-in $ [:shapes-by-id tid :items] (conj shapes sid))
|
||||
(update-in $ [:shapes-by-id sid] assoc :group tid))
|
||||
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
Reference in a new issue