mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 23:18:48 -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,36 +117,38 @@
|
|||
:ry (mth/abs (- y2 y1))))
|
||||
|
||||
(defmethod move-vertex ::rect
|
||||
[shape vid {dx :x dy :y}]
|
||||
(case vid
|
||||
1 (assoc shape
|
||||
:x1 (+ (:x1 shape) dx)
|
||||
:y1 (+ (:y1 shape) dy))
|
||||
2 (assoc shape
|
||||
:x2 (+ (:x2 shape) dx)
|
||||
:y1 (+ (:y1 shape) dy))
|
||||
3 (assoc shape
|
||||
:x1 (+ (:x1 shape) dx)
|
||||
:y2 (+ (:y2 shape) dy))
|
||||
4 (assoc shape
|
||||
:x2 (+ (:x2 shape) dx)
|
||||
:y2 (+ (:y2 shape) dy))))
|
||||
[shape vid {dx :x dy :y lock :lock}]
|
||||
(let [[dx dy] (if lock [dx dx] [dx dy])]
|
||||
(case vid
|
||||
1 (assoc shape
|
||||
:x1 (+ (:x1 shape) dx)
|
||||
:y1 (+ (:y1 shape) dy))
|
||||
2 (assoc shape
|
||||
:x2 (+ (:x2 shape) dx)
|
||||
:y1 (+ (:y1 shape) dy))
|
||||
3 (assoc shape
|
||||
:x1 (+ (:x1 shape) dx)
|
||||
:y2 (+ (:y2 shape) dy))
|
||||
4 (assoc shape
|
||||
:x2 (+ (:x2 shape) dx)
|
||||
:y2 (+ (:y2 shape) dy)))))
|
||||
|
||||
(defmethod move-vertex :builtin/circle
|
||||
[shape vid {dx :x dy :y}]
|
||||
(case vid
|
||||
1 (assoc shape
|
||||
:rx (- (:rx shape) dx)
|
||||
:ry (- (:ry shape) dy))
|
||||
2 (assoc shape
|
||||
:rx (+ (:rx shape) dx)
|
||||
:ry (- (:ry shape) dy))
|
||||
3 (assoc shape
|
||||
:rx (- (:rx shape) dx)
|
||||
:ry (+ (:ry shape) dy))
|
||||
4 (assoc shape
|
||||
:rx (+ (:rx shape) dx)
|
||||
:ry (+ (:ry shape) dy))))
|
||||
[shape vid {dx :x dy :y lock :lock}]
|
||||
(let [[dx dy] (if lock [dx dx] [dx dy])]
|
||||
(case vid
|
||||
1 (assoc shape
|
||||
:rx (- (:rx shape) dx)
|
||||
:ry (- (:ry shape) dy))
|
||||
2 (assoc shape
|
||||
:rx (+ (:rx shape) dx)
|
||||
:ry (- (:ry shape) dy))
|
||||
3 (assoc shape
|
||||
:rx (- (:rx shape) dx)
|
||||
:ry (+ (:ry shape) dy))
|
||||
4 (assoc shape
|
||||
:rx (+ (:rx shape) dx)
|
||||
:ry (+ (:ry shape) dy)))))
|
||||
|
||||
;; FIXME: lock mode
|
||||
|
||||
|
|
|
@ -16,23 +16,20 @@
|
|||
[uxbox.util.dom :as dom]))
|
||||
|
||||
(define-once :resize-subscriptions
|
||||
(letfn [(init [{:keys [payload]}]
|
||||
(println payload)
|
||||
(let [stoper (->> uuc/actions-s
|
||||
(letfn [(init [event]
|
||||
(let [payload (:payload event)
|
||||
stoper (->> uuc/actions-s
|
||||
(rx/map :type)
|
||||
(rx/pr-log "kaka:")
|
||||
(rx/filter #(= :nothing %))
|
||||
(rx/take 1))]
|
||||
(as-> uuwb/mouse-delta-s $
|
||||
(rx/take-until stoper $)
|
||||
(rx/subscribe
|
||||
$ #(on-value payload %) nil on-complete))))
|
||||
(rx/with-latest-from vector uuwb/mouse-ctrl-s $)
|
||||
(rx/subscribe $ #(on-value payload %)))))
|
||||
|
||||
(on-complete []
|
||||
(println "on-complete"))
|
||||
|
||||
(on-value [{:keys [vid shape]} delta]
|
||||
(let [params {:vid vid :delta delta}]
|
||||
(on-value [{:keys [vid shape]} [delta ctrl?]]
|
||||
(let [params {:vid vid :delta (assoc delta :lock ctrl?)}]
|
||||
(rs/emit! (uds/update-vertex-position shape params))))]
|
||||
|
||||
(as-> uuc/actions-s $
|
||||
|
|
Loading…
Add table
Reference in a new issue