[Fixed Position] Update positions when grid size changes

Update positions of elements in a fixed position
view when grid size changes (e.g. when switching
from one domain object to another.) WTD-1344.
This commit is contained in:
Victor Woeltjen 2015-06-25 10:45:50 -07:00
parent d3ff49b90b
commit 791504584d

View File

@ -60,7 +60,7 @@ define(
cellStyles = [];
// Update grid size from model
gridSize = ($scope.model || {}).layoutGrid || gridSize;
gridSize = ($scope.model || {}).layoutGrid || DEFAULT_GRID_SIZE;
for (x = 0; x < gridExtent[0]; x += 1) {
for (y = 0; y < gridExtent[1]; y += 1) {
@ -136,6 +136,16 @@ define(
}
}
// Update element positions when grid size changes
function updateElementPositions(layoutGrid) {
// Update grid size from model
gridSize = layoutGrid || DEFAULT_GRID_SIZE;
elementProxies.forEach(function (elementProxy) {
elementProxy.style = convertPosition(elementProxy);
});
}
// Update telemetry values based on new data available
function updateValues() {
if (subscription) {
@ -277,6 +287,9 @@ define(
// Position panes when the model field changes
$scope.$watch("model.composition", updateComposition);
// Detect changes to grid size
$scope.$watch("model.layoutGrid", updateElementPositions);
// Subscribe to telemetry when an object is available
$scope.$watch("domainObject", subscribe);
@ -372,4 +385,4 @@ define(
return FixedController;
}
);
);