mirror of
https://github.com/penpot/penpot.git
synced 2025-02-10 09:08:31 -05:00
🎉 Adds feedback when dragging interactions
This commit is contained in:
parent
3b0ea9b7fd
commit
353e86c49d
3 changed files with 23 additions and 9 deletions
|
@ -1296,21 +1296,29 @@
|
|||
(ptk/reify ::move-create-interaction
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(if (= position initial-pos)
|
||||
state
|
||||
(assoc-in state [:workspace-local :draw-interaction-to] position)))))
|
||||
(let [page-id (:current-page-id state)
|
||||
objects (get-in state [:workspace-data page-id :objects])
|
||||
selected-shape-id (-> state (get-in [:workspace-local :selected]) first)
|
||||
selected-shape (get objects selected-shape-id)
|
||||
selected-shape-frame-id (:frame-id selected-shape)
|
||||
start-frame (get objects selected-shape-frame-id)
|
||||
end-frame (dwc/get-frame-at-point objects position)]
|
||||
(cond-> state
|
||||
(not= position initial-pos) (assoc-in [:workspace-local :draw-interaction-to] position)
|
||||
(not= start-frame end-frame) (assoc-in [:workspace-local :draw-interaction-to-frame] end-frame))))))
|
||||
|
||||
(defn finish-create-interaction
|
||||
[initial-pos]
|
||||
(ptk/reify ::finish-create-interaction
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc-in state [:workspace-local :draw-interaction-to] nil))
|
||||
(-> state
|
||||
(assoc-in [:workspace-local :draw-interaction-to] nil)
|
||||
(assoc-in [:workspace-local :draw-interaction-to-frame] nil)))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [position @ms/mouse-position
|
||||
|
||||
page-id (:current-page-id state)
|
||||
objects (get-in state [:workspace-data page-id :objects])
|
||||
frame (dwc/get-frame-at-point objects position)
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
[uxbox.main.store :as st]
|
||||
[uxbox.main.refs :as refs]
|
||||
[uxbox.main.data.workspace :as dw]
|
||||
[uxbox.main.ui.keyboard :as kbd]))
|
||||
[uxbox.main.ui.keyboard :as kbd]
|
||||
[uxbox.main.ui.workspace.shapes.outline :refer [outline]]))
|
||||
|
||||
(defn- get-click-interaction
|
||||
[shape]
|
||||
|
@ -154,7 +155,10 @@
|
|||
[:& interaction-marker {:x dest-x
|
||||
:y dest-y
|
||||
:arrow-dir arrow-dir
|
||||
:zoom zoom}]])))
|
||||
:zoom zoom}]
|
||||
|
||||
(when dest-shape
|
||||
[:& outline {:shape dest-shape}])])))
|
||||
|
||||
|
||||
(mf/defc interaction-handle
|
||||
|
@ -179,6 +183,7 @@
|
|||
active-shapes (filter #(first (get-click-interaction %)) (vals objects))
|
||||
selected-shapes (map #(get objects %) selected)
|
||||
draw-interaction-to (:draw-interaction-to local)
|
||||
draw-interaction-to-frame (:draw-interaction-to-frame local)
|
||||
first-selected (first selected-shapes)]
|
||||
[:*
|
||||
(for [shape active-shapes]
|
||||
|
@ -197,6 +202,7 @@
|
|||
[:& interaction-path {:key "interactive"
|
||||
:orig-shape first-selected
|
||||
:dest-point draw-interaction-to
|
||||
:dest-shape draw-interaction-to-frame
|
||||
:selected? true
|
||||
:zoom zoom}]
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
|
||||
common {:fill "transparent"
|
||||
:stroke "#31EFB8"
|
||||
:stroke-width "1px"
|
||||
:pointer-events "none"
|
||||
:strokeWidth "1px"
|
||||
:pointerEvents "none"
|
||||
:transform transform}
|
||||
|
||||
props (case (:type shape)
|
||||
|
|
Loading…
Add table
Reference in a new issue