From 5c1b007c1b1ea6e18ef0d9205270efb1a2de1f65 Mon Sep 17 00:00:00 2001 From: Eva Date: Fri, 28 Jan 2022 10:30:37 +0100 Subject: [PATCH] :sparkles: Align item to it's parent --- CHANGES.md | 7 ++++--- frontend/src/app/main/data/workspace.cljs | 11 ++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 470721886..11eee7087 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,12 +6,13 @@ ### :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). -- 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). - 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 ### :arrow_up: Deps updates diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 4e910febd..56b69b5bc 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -1148,7 +1148,7 @@ ;; --- Shape / Selection Alignment and Distribution -(declare align-object-to-frame) +(declare align-object-to-parent) (declare align-objects-list) (defn can-align? [selected objects] @@ -1168,7 +1168,7 @@ objects (wsh/lookup-page-objects state page-id) selected (wsh/lookup-selected state) 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)) moved-objects (->> moved (group-by :id)) ids (keys moved-objects) @@ -1176,11 +1176,12 @@ (when (can-align? selected objects) (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] (let [object (get objects object-id) - frame (get objects (:frame-id object))] - (gal/align-to-rect object frame axis objects))) + parent (:parent-id (get objects object-id)) + parent-obj (get objects parent)] + (gal/align-to-rect object parent-obj axis objects))) (defn align-objects-list [objects selected axis]