🐛 Synchronize text positions in components

This commit is contained in:
Andrés Moya 2022-05-17 09:59:09 +02:00 committed by Alonso Torres
parent fa00d674eb
commit d666755159
6 changed files with 84 additions and 18 deletions

View file

@ -252,15 +252,23 @@
shape-delta
(when root
(gpt/point (- (:x shape) (:x root))
(- (:y shape) (:y root))))
(gpt/point (- (gsh/left-bound shape) (gsh/left-bound root))
(- (gsh/top-bound shape) (gsh/top-bound root))))
transformed-shape-delta
(when transformed-root
(gpt/point (- (:x transformed-shape) (:x transformed-root))
(- (:y transformed-shape) (:y transformed-root))))
(gpt/point (- (gsh/left-bound transformed-shape) (gsh/left-bound transformed-root))
(- (gsh/top-bound transformed-shape) (gsh/top-bound transformed-root))))
ignore-geometry? (= shape-delta transformed-shape-delta)]
;; There are cases in that the coordinates change slightly (e.g. when
;; rounding to pixel, or when recalculating text positions in different
;; zoom levels). To take this into account, we ignore movements smaller
;; than 1 pixel.
distance (if (and shape-delta transformed-shape-delta)
(gpt/distance-vector shape-delta transformed-shape-delta)
(gpt/point 0 0))
ignore-geometry? (and (< (:x distance) 1) (< (:y distance) 1))]
[root transformed-root ignore-geometry?]))

View file

@ -72,7 +72,6 @@
(defn- update-text-modifier
[{:keys [grow-type id]} node]
(let [position-data (utp/calc-position-data node)
props {:position-data position-data}