mirror of
https://github.com/penpot/penpot.git
synced 2026-08-01 10:56:20 +00:00
Merge pull request #8022 from penpot/alotor-fix-drag-handlers
🐛 Fix problem with dragging handlers
This commit is contained in:
commit
60aa426753
@ -112,8 +112,10 @@
|
|||||||
(:c2y params) (update-in [index :params :c2y] + (:c2y params)))
|
(:c2y params) (update-in [index :params :c2y] + (:c2y params)))
|
||||||
content))]
|
content))]
|
||||||
|
|
||||||
(impl/path-data
|
(if (some? modifiers)
|
||||||
(reduce apply-to-index (vec content) modifiers))))
|
(impl/path-data
|
||||||
|
(reduce apply-to-index (vec content) modifiers))
|
||||||
|
content)))
|
||||||
|
|
||||||
(defn transform-content
|
(defn transform-content
|
||||||
"Applies a transformation matrix over content and returns a new
|
"Applies a transformation matrix over content and returns a new
|
||||||
|
|||||||
@ -47,32 +47,31 @@
|
|||||||
(ptk/reify ::apply-content-modifiers
|
(ptk/reify ::apply-content-modifiers
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
(let [page-id (get state :current-page-id state)
|
(let [id (st/get-path-id state)
|
||||||
objects (dsh/lookup-page-objects state)
|
shape (st/get-path state)
|
||||||
|
|
||||||
id (st/get-path-id state)
|
|
||||||
|
|
||||||
shape
|
|
||||||
(st/get-path state)
|
|
||||||
|
|
||||||
content-modifiers
|
content-modifiers
|
||||||
(dm/get-in state [:workspace-local :edit-path id :content-modifiers])
|
(dm/get-in state [:workspace-local :edit-path id :content-modifiers])]
|
||||||
|
(if (or (nil? shape) (nil? content-modifiers))
|
||||||
|
(rx/of (dwe/clear-edition-mode))
|
||||||
|
(let [page-id (get state :current-page-id state)
|
||||||
|
objects (dsh/lookup-page-objects state)
|
||||||
|
|
||||||
content (get shape :content)
|
content (get shape :content)
|
||||||
new-content (path/apply-content-modifiers content content-modifiers)
|
new-content (path/apply-content-modifiers content content-modifiers)
|
||||||
|
|
||||||
old-points (path.segment/get-points content)
|
old-points (path.segment/get-points content)
|
||||||
new-points (path.segment/get-points new-content)
|
new-points (path.segment/get-points new-content)
|
||||||
point-change (->> (map hash-map old-points new-points) (reduce merge))]
|
point-change (->> (map hash-map old-points new-points) (reduce merge))]
|
||||||
|
|
||||||
(when (and (some? new-content) (some? shape))
|
(when (and (some? new-content) (some? shape))
|
||||||
(let [changes (changes/generate-path-changes it objects page-id shape (:content shape) new-content)]
|
(let [changes (changes/generate-path-changes it objects page-id shape (:content shape) new-content)]
|
||||||
(if (empty? new-content)
|
(if (empty? new-content)
|
||||||
(rx/of (dch/commit-changes changes)
|
(rx/of (dch/commit-changes changes)
|
||||||
(dwe/clear-edition-mode))
|
(dwe/clear-edition-mode))
|
||||||
(rx/of (dch/commit-changes changes)
|
(rx/of (dch/commit-changes changes)
|
||||||
(selection/update-selection point-change)
|
(selection/update-selection point-change)
|
||||||
(fn [state] (update-in state [:workspace-local :edit-path id] dissoc :content-modifiers :moving-nodes :moving-handler))))))))))
|
(fn [state] (update-in state [:workspace-local :edit-path id] dissoc :content-modifiers :moving-nodes :moving-handler))))))))))))
|
||||||
|
|
||||||
(defn modify-content-point
|
(defn modify-content-point
|
||||||
[content {dx :x dy :y} modifiers point]
|
[content {dx :x dy :y} modifiers point]
|
||||||
|
|||||||
@ -148,11 +148,12 @@
|
|||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps index prefix is-move)
|
(mf/deps index prefix is-move)
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(dom/stop-propagation event)
|
(when (dom/left-mouse? event)
|
||||||
(dom/prevent-default event)
|
(dom/stop-propagation event)
|
||||||
|
(dom/prevent-default event)
|
||||||
|
|
||||||
(when ^boolean is-move
|
(when ^boolean is-move
|
||||||
(st/emit! (drp/start-move-handler index prefix)))))]
|
(st/emit! (drp/start-move-handler index prefix))))))]
|
||||||
|
|
||||||
[:g.handler {:pointer-events (if ^boolean is-draw "none" "visible")}
|
[:g.handler {:pointer-events (if ^boolean is-draw "none" "visible")}
|
||||||
[:line
|
[:line
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user