Align item to it's parent

This commit is contained in:
Eva 2022-01-28 10:30:37 +01:00 committed by Andrés Moya
parent 86c394f4ce
commit 5c1b007c1b
2 changed files with 10 additions and 8 deletions

View file

@ -6,12 +6,13 @@
### :sparkles: New features ### :sparkles: New features
- Scroll bars [Taiga #2550](https://tree.taiga.io/project/penpot/task/2550) - Allow to align items relative to groups [Taiga #2533](https://tree.taiga.io/project/penpot/us/2533).
- Scroll bars [Taiga #2550](https://tree.taiga.io/project/penpot/task/2550).
- Add select layer option to context menu [Taiga #2474](https://tree.taiga.io/project/penpot/us/2474). - Add select layer option to context menu [Taiga #2474](https://tree.taiga.io/project/penpot/us/2474).
- Guides [Taiga #290](https://tree.taiga.io/project/penpot/us/290) - Guides [Taiga #290](https://tree.taiga.io/project/penpot/us/290).
- Improve file menu by adding semantically groups [Github #1203](https://github.com/penpot/penpot/issues/1203). - Improve file menu by adding semantically groups [Github #1203](https://github.com/penpot/penpot/issues/1203).
- Add update components in bulk option in context menu [Taiga #1975](https://tree.taiga.io/project/penpot/us/1975). - Add update components in bulk option in context menu [Taiga #1975](https://tree.taiga.io/project/penpot/us/1975).
- Create first E2E tests [Taiga #2608](https://tree.taiga.io/project/penpot/task/2608), [Taiga #2608](https://tree.taiga.io/project/penpot/task/2608) - Create first E2E tests [Taiga #2608](https://tree.taiga.io/project/penpot/task/2608), [Taiga #2608](https://tree.taiga.io/project/penpot/task/2608).
### :bug: Bugs fixed ### :bug: Bugs fixed
### :arrow_up: Deps updates ### :arrow_up: Deps updates

View file

@ -1148,7 +1148,7 @@
;; --- Shape / Selection Alignment and Distribution ;; --- Shape / Selection Alignment and Distribution
(declare align-object-to-frame) (declare align-object-to-parent)
(declare align-objects-list) (declare align-objects-list)
(defn can-align? [selected objects] (defn can-align? [selected objects]
@ -1168,7 +1168,7 @@
objects (wsh/lookup-page-objects state page-id) objects (wsh/lookup-page-objects state page-id)
selected (wsh/lookup-selected state) selected (wsh/lookup-selected state)
moved (if (= 1 (count selected)) moved (if (= 1 (count selected))
(align-object-to-frame objects (first selected) axis) (align-object-to-parent objects (first selected) axis)
(align-objects-list objects selected axis)) (align-objects-list objects selected axis))
moved-objects (->> moved (group-by :id)) moved-objects (->> moved (group-by :id))
ids (keys moved-objects) ids (keys moved-objects)
@ -1176,11 +1176,12 @@
(when (can-align? selected objects) (when (can-align? selected objects)
(rx/of (dch/update-shapes ids update-fn {:reg-objects? true}))))))) (rx/of (dch/update-shapes ids update-fn {:reg-objects? true})))))))
(defn align-object-to-frame (defn align-object-to-parent
[objects object-id axis] [objects object-id axis]
(let [object (get objects object-id) (let [object (get objects object-id)
frame (get objects (:frame-id object))] parent (:parent-id (get objects object-id))
(gal/align-to-rect object frame axis objects))) parent-obj (get objects parent)]
(gal/align-to-rect object parent-obj axis objects)))
(defn align-objects-list (defn align-objects-list
[objects selected axis] [objects selected axis]