From c306865d873db28de6a1ab0e0da000d394ac1f2f Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 24 Feb 2015 11:22:52 -0800 Subject: [PATCH] [Fixed Position] Update style during resize Update element style during resize, WTD-882. --- .../features/layout/res/templates/fixed.html | 5 ++-- .../features/layout/src/FixedController.js | 30 ++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/platform/features/layout/res/templates/fixed.html b/platform/features/layout/res/templates/fixed.html index dbe03ef22a..ea48e019b7 100644 --- a/platform/features/layout/res/templates/fixed.html +++ b/platform/features/layout/res/templates/fixed.html @@ -15,7 +15,6 @@ style="position: absolute;" key="element.template" parameters="{ gridSize: controller.getGridSize() }" - ng-class="{ test: controller.selected(element) }" ng-style="element.style" ng-click="controller.select(element)" ng-model="element"> @@ -26,7 +25,7 @@
@@ -34,7 +33,7 @@ style="position: absolute;" ng-style="handle.style()" mct-drag-down="handle.startDrag()" - mct-drag="handle.continueDrag(delta)" + mct-drag="handle.continueDrag(delta); controller.updateStyle(controller.selected())" mct-drag-up="handle.endDrag()"> O diff --git a/platform/features/layout/src/FixedController.js b/platform/features/layout/src/FixedController.js index d40699ff8a..d198041e69 100644 --- a/platform/features/layout/src/FixedController.js +++ b/platform/features/layout/src/FixedController.js @@ -63,6 +63,16 @@ define( return element.handles().map(generateDragHandle); } + // Select an element + function select(element) { + if (selection) { + // Update selection... + selection.select(element); + // ...as well as drag handles + handles = generateDragHandles(element); + } + } + // Convert from element x/y/width/height to an // apropriate ng-style argument, to position elements. function convertPosition(elementProxy) { @@ -132,7 +142,7 @@ define( if (selection) { selection.deselect(); if (index > -1) { - selection.select(elementProxies[index]); + select(elementProxies[index]); } } @@ -194,9 +204,7 @@ define( // Refresh displayed elements refreshElements(); // Select the newly-added element - if (selection) { - selection.select(elementProxies[elementProxies.length - 1]); - } + select(elementProxies[elementProxies.length - 1]); // Mark change as persistable if ($scope.commit) { $scope.commit("Dropped an element."); @@ -298,12 +306,7 @@ define( * Set the active user selection in this view. * @param element the element to select */ - select: function (element) { - if (selection) { - selection.select(element); - handles = generateDragHandles(element); - } - }, + select: select, /** * Clear the current user selection. */ @@ -320,6 +323,13 @@ define( handles: function () { return handles; }, + /** + * Update the style (for position/sizing) for the specified + * element. + */ + updateStyle: function (element) { + element.style = convertPosition(element); + }, /** * Start a drag gesture to move/resize a frame. *