From c89f2fc627e042e63177ee75404a066d325b65f4 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 6 Jun 2023 14:03:08 +0200 Subject: [PATCH] :bug: Fix align.cljc lint --- common/src/app/common/geom/align.cljc | 35 +++++++++++++-------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/common/src/app/common/geom/align.cljc b/common/src/app/common/geom/align.cljc index ea9e8e81b..7c2091cb9 100644 --- a/common/src/app/common/geom/align.cljc +++ b/common/src/app/common/geom/align.cljc @@ -84,28 +84,27 @@ ; Each shape wrapped in its own rectangle wrapped-shapes (map #(gsh/selection-rect [%]) sorted-shapes) ; The total space between shapes - space (reduce - (size wrapper-rect) (map size wrapped-shapes))] + space (reduce - (size wrapper-rect) (map size wrapped-shapes)) + unit-space (/ space (- (count wrapped-shapes) 1)) + ; Calculate the distance we need to move each shape. + ; The new position of each one is the position of the + ; previous one plus its size plus the unit space. + deltas (loop [shapes' wrapped-shapes + start-pos (coord wrapper-rect) + deltas []] - (let [unit-space (/ space (- (count wrapped-shapes) 1)) - ; Calculate the distance we need to move each shape. - ; The new position of each one is the position of the - ; previous one plus its size plus the unit space. - deltas (loop [shapes' wrapped-shapes - start-pos (coord wrapper-rect) - deltas []] + (let [first-shape (first shapes') + delta (- start-pos (coord first-shape)) + new-pos (+ start-pos (size first-shape) unit-space)] - (let [first-shape (first shapes') - delta (- start-pos (coord first-shape)) - new-pos (+ start-pos (size first-shape) unit-space)] - - (if (= (count shapes') 1) - (conj deltas delta) - (recur (rest shapes') - new-pos - (conj deltas delta)))))] + (if (= (count shapes') 1) + (conj deltas delta) + (recur (rest shapes') + new-pos + (conj deltas delta)))))] (mapcat #(recursive-move %1 {coord %2 other-coord 0} objects) - sorted-shapes deltas)))) + sorted-shapes deltas))) ;; Adjust to viewport