Skip to content

Commit 685223c

Browse files
committed
revert child positioning on recurring scale
1 parent 78311f4 commit 685223c

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

.clj-kondo/metosin/malli-types-cljs/config.edn

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6549,7 +6549,7 @@
65496549
:pen-mode :boolean}}
65506550
:any],
65516551
:ret :vector}}},
6552-
duplicate {:arities {2 {:args [{:op :keys,
6552+
duplicate {:arities {1 {:args [{:op :keys,
65536553
:opt {:explanation :string,
65546554
:system-fonts :vector,
65556555
:copied-bounds :seqable,
@@ -6622,8 +6622,7 @@
66226622
:panels :map,
66236623
:worker {:op :keys,
66246624
:req {:tasks :map}},
6625-
:pen-mode :boolean}}
6626-
:seqable],
6625+
:pen-mode :boolean}}],
66276626
:ret {:op :keys,
66286627
:opt {:explanation :string,
66296628
:system-fonts :vector,

src/renderer/element/events.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
[(finalize "Scale selection")]
207207
(fn [db [_ ratio]]
208208
(let [pivot-point (-> db h/bounds bounds/center)]
209-
(h/scale db ratio pivot-point {}))))
209+
(h/scale db ratio pivot-point false))))
210210

211211
(rf/reg-event-db
212212
::move-up

src/renderer/element/handlers.cljs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
[renderer.utils.extra :refer [partial-right]]
2020
[renderer.utils.hiccup :as hiccup]
2121
[renderer.utils.map :as map]
22-
[renderer.utils.math :refer [Vec2D]]
2322
[renderer.utils.path :as path]
2423
[renderer.utils.vec :as vec]))
2524

@@ -534,19 +533,12 @@
534533
(update-el db id hierarchy/place pos)))
535534

536535
(defn scale
537-
[db ratio pivot-point {:keys [in-place recursive]}]
536+
[db ratio pivot-point recursive]
538537
(let [ids-to-scale (cond-> (selected-ids db) recursive (set/union (descendant-ids db)))]
539538
(reduce
540539
(fn [db id]
541-
(let [pivot-point (->> (entity db id) :bounds (take 2) (mat/sub pivot-point))
542-
db (update-el db id hierarchy/scale ratio pivot-point)]
543-
(if in-place
544-
;; FIXME: Handle locked ratio.
545-
(let [pointer-delta (mat/sub (:adjusted-pointer-pos db) (:adjusted-pointer-offset db))
546-
child-ids (set (children-ids db id))
547-
child-ids (set/intersection child-ids ids-to-scale)]
548-
(reduce (partial-right translate pointer-delta) db child-ids))
549-
db)))
540+
(let [pivot-point (->> (entity db id) :bounds (take 2) (mat/sub pivot-point))]
541+
(update-el db id hierarchy/scale ratio pivot-point)))
550542
db
551543
ids-to-scale)))
552544

src/renderer/tool/impl/base/transform.cljs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202

203203
(m/=> scale [:-> App Vec2D map? App])
204204
(defn scale
205-
[db offset {:keys [ratio-locked in-place] :as options}]
205+
[db offset {:keys [ratio-locked in-place recursive]}]
206206
(let [handle (-> db :clicked-element :id)
207207
bounds (element.h/bounds db)
208208
[offset pivot-point] (delta->scale-with-pivot-point handle offset bounds)
@@ -211,11 +211,11 @@
211211
dimensions (bounds/->dimensions bounds)
212212
ratio (mat/div (mat/add dimensions offset) dimensions)
213213
ratio (cond-> ratio ratio-locked (lock-ratio handle))
214-
;; TODO: Handle negative ratio.
214+
;; TODO: Handle negative ratio, and position on recursive scale.
215215
ratio (mapv #(max % 0.01) ratio)]
216216
(-> db
217217
(assoc :pivot-point pivot-point)
218-
(element.h/scale ratio pivot-point options))))
218+
(element.h/scale ratio pivot-point recursive))))
219219

220220
(m/=> select-element [:-> App boolean? App])
221221
(defn select-element

0 commit comments

Comments
 (0)