mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 15:39:50 -05:00
Add lock mode for mouse resize interaction.
Signed-off-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
parent
5c7188eeba
commit
ffaca0f459
2 changed files with 37 additions and 38 deletions
|
@ -117,7 +117,8 @@
|
||||||
:ry (mth/abs (- y2 y1))))
|
:ry (mth/abs (- y2 y1))))
|
||||||
|
|
||||||
(defmethod move-vertex ::rect
|
(defmethod move-vertex ::rect
|
||||||
[shape vid {dx :x dy :y}]
|
[shape vid {dx :x dy :y lock :lock}]
|
||||||
|
(let [[dx dy] (if lock [dx dx] [dx dy])]
|
||||||
(case vid
|
(case vid
|
||||||
1 (assoc shape
|
1 (assoc shape
|
||||||
:x1 (+ (:x1 shape) dx)
|
:x1 (+ (:x1 shape) dx)
|
||||||
|
@ -130,10 +131,11 @@
|
||||||
:y2 (+ (:y2 shape) dy))
|
:y2 (+ (:y2 shape) dy))
|
||||||
4 (assoc shape
|
4 (assoc shape
|
||||||
:x2 (+ (:x2 shape) dx)
|
:x2 (+ (:x2 shape) dx)
|
||||||
:y2 (+ (:y2 shape) dy))))
|
:y2 (+ (:y2 shape) dy)))))
|
||||||
|
|
||||||
(defmethod move-vertex :builtin/circle
|
(defmethod move-vertex :builtin/circle
|
||||||
[shape vid {dx :x dy :y}]
|
[shape vid {dx :x dy :y lock :lock}]
|
||||||
|
(let [[dx dy] (if lock [dx dx] [dx dy])]
|
||||||
(case vid
|
(case vid
|
||||||
1 (assoc shape
|
1 (assoc shape
|
||||||
:rx (- (:rx shape) dx)
|
:rx (- (:rx shape) dx)
|
||||||
|
@ -146,7 +148,7 @@
|
||||||
:ry (+ (:ry shape) dy))
|
:ry (+ (:ry shape) dy))
|
||||||
4 (assoc shape
|
4 (assoc shape
|
||||||
:rx (+ (:rx shape) dx)
|
:rx (+ (:rx shape) dx)
|
||||||
:ry (+ (:ry shape) dy))))
|
:ry (+ (:ry shape) dy)))))
|
||||||
|
|
||||||
;; FIXME: lock mode
|
;; FIXME: lock mode
|
||||||
|
|
||||||
|
|
|
@ -16,23 +16,20 @@
|
||||||
[uxbox.util.dom :as dom]))
|
[uxbox.util.dom :as dom]))
|
||||||
|
|
||||||
(define-once :resize-subscriptions
|
(define-once :resize-subscriptions
|
||||||
(letfn [(init [{:keys [payload]}]
|
(letfn [(init [event]
|
||||||
(println payload)
|
(let [payload (:payload event)
|
||||||
(let [stoper (->> uuc/actions-s
|
stoper (->> uuc/actions-s
|
||||||
(rx/map :type)
|
(rx/map :type)
|
||||||
(rx/pr-log "kaka:")
|
(rx/pr-log "kaka:")
|
||||||
(rx/filter #(= :nothing %))
|
(rx/filter #(= :nothing %))
|
||||||
(rx/take 1))]
|
(rx/take 1))]
|
||||||
(as-> uuwb/mouse-delta-s $
|
(as-> uuwb/mouse-delta-s $
|
||||||
(rx/take-until stoper $)
|
(rx/take-until stoper $)
|
||||||
(rx/subscribe
|
(rx/with-latest-from vector uuwb/mouse-ctrl-s $)
|
||||||
$ #(on-value payload %) nil on-complete))))
|
(rx/subscribe $ #(on-value payload %)))))
|
||||||
|
|
||||||
(on-complete []
|
(on-value [{:keys [vid shape]} [delta ctrl?]]
|
||||||
(println "on-complete"))
|
(let [params {:vid vid :delta (assoc delta :lock ctrl?)}]
|
||||||
|
|
||||||
(on-value [{:keys [vid shape]} delta]
|
|
||||||
(let [params {:vid vid :delta delta}]
|
|
||||||
(rs/emit! (uds/update-vertex-position shape params))))]
|
(rs/emit! (uds/update-vertex-position shape params))))]
|
||||||
|
|
||||||
(as-> uuc/actions-s $
|
(as-> uuc/actions-s $
|
||||||
|
|
Loading…
Add table
Reference in a new issue