|
4 | 4 | * UI.Layout |
5 | 5 | */ |
6 | 6 | angular.module('ui.layout', []) |
7 | | - .controller('uiLayoutCtrl', ['$scope', '$attrs', '$element', 'LayoutContainer', function uiLayoutCtrl($scope, $attrs, $element, LayoutContainer) { |
| 7 | + .controller('uiLayoutCtrl', ['$scope', '$attrs', '$element', '$timeout', 'LayoutContainer', function uiLayoutCtrl($scope, $attrs, $element, $timeout, LayoutContainer) { |
8 | 8 | var ctrl = this; |
9 | 9 | var opts = angular.extend({}, $scope.$eval($attrs.uiLayout), $scope.$eval($attrs.options)); |
10 | 10 | var numOfSplitbars = 0; |
@@ -43,6 +43,7 @@ angular.module('ui.layout', []) |
43 | 43 | ctrl.updateDisplay(); |
44 | 44 | }; |
45 | 45 |
|
| 46 | + var debounceEvent; |
46 | 47 | function draw() { |
47 | 48 | var position = ctrl.sizeProperties.flowProperty; |
48 | 49 | var dividerSize = parseInt(opts.dividerSize); |
@@ -90,7 +91,12 @@ angular.module('ui.layout', []) |
90 | 91 | // move the splitbar |
91 | 92 | ctrl.movingSplitbar[position] = newPosition; |
92 | 93 |
|
93 | | - //TODO: dispatch container resize event |
| 94 | + // broadcast an event that resize happened (debounced to 50ms) |
| 95 | + if(debounceEvent) $timeout.cancel(debounceEvent); |
| 96 | + debounceEvent = $timeout(function() { |
| 97 | + $scope.$broadcast('ui.layout.resize', beforeContainer, afterContainer); |
| 98 | + debounceEvent = null; |
| 99 | + }, 50); |
94 | 100 | } |
95 | 101 | } |
96 | 102 | } |
@@ -395,6 +401,7 @@ angular.module('ui.layout', []) |
395 | 401 | } |
396 | 402 | } |
397 | 403 | }); |
| 404 | + $scope.$broadcast('ui.layout.toggle', c); |
398 | 405 |
|
399 | 406 | return c.collapsed; |
400 | 407 | }; |
@@ -439,6 +446,7 @@ angular.module('ui.layout', []) |
439 | 446 | if(prevContainer) prevContainer.size -= (c.actualSize + endDiff); |
440 | 447 | } |
441 | 448 | }); |
| 449 | + $scope.$broadcast('ui.layout.toggle', c); |
442 | 450 |
|
443 | 451 | return c.collapsed; |
444 | 452 | }; |
|
0 commit comments