0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 07:50:43 -05:00

🐛 Fixes problems with paste empty text

This commit is contained in:
alonso.torres 2021-02-02 15:36:49 +01:00
parent e713c30785
commit 8aedbd1418
3 changed files with 8 additions and 3 deletions

View file

@ -1564,7 +1564,7 @@
(watch [_ state stream]
(let [id (uuid/next)
{:keys [x y]} @ms/mouse-position
width (min (* 7 (count text)) 700)
width (max 8 (min (* 7 (count text)) 700))
height 16
page-id (:current-page-id state)
frame-id (-> (dwc/lookup-page-objects state page-id)

View file

@ -21,12 +21,17 @@
[app.main.data.workspace.drawing.common :as common]
[app.common.math :as mth]))
(defn truncate-zero [num default]
(if (mth/almost-zero? num) default num))
(defn resize-shape [{:keys [x y width height transform transform-inverse] :as shape} point lock?]
(let [;; The new shape behaves like a resize on the bottom-right corner
initial (gpt/point (+ x width) (+ y height))
shapev (gpt/point width height)
deltav (gpt/to-vec initial point)
scalev (gpt/divide (gpt/add shapev deltav) shapev)
scalev (-> (gpt/divide (gpt/add shapev deltav) shapev)
(update :x truncate-zero 1)
(update :y truncate-zero 1))
scalev (if lock?
(let [v (max (:x scalev) (:y scalev))]
(gpt/point v v))

View file

@ -176,7 +176,7 @@
:y cy'
:width resize-point-circle-radius
:height resize-point-circle-radius
:transform (str/fmt "rotate(%s, %s, %s)" rotation cx' cy')
:transform (when rotation (str/fmt "rotate(%s, %s, %s)" rotation cx' cy'))
:style {:fill (if (debug? :resize-handler) "red" "transparent")
:cursor cursor}
:on-mouse-down #(on-resize {:x cx' :y cy'} %)}])