Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 600fab1

Browse files
committed
Merge pull request #1535 from wesleycho/feat/optimize-update
feat(perf): optimize width resizing
2 parents c9232e8 + b9d7523 commit 600fab1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/uiSelectController.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ uis.controller('uiSelectCtrl',
444444
};
445445

446446
var sizeWatch = null;
447+
var updaterScheduled = false;
447448
ctrl.sizeSearchInput = function() {
448449

449450
var input = ctrl.searchInput[0],
@@ -465,10 +466,16 @@ uis.controller('uiSelectCtrl',
465466
ctrl.searchInput.css('width', '10px');
466467
$timeout(function() { //Give tags time to render correctly
467468
if (sizeWatch === null && !updateIfVisible(calculateContainerWidth())) {
468-
sizeWatch = $scope.$watch(calculateContainerWidth, function(containerWidth) {
469-
if (updateIfVisible(containerWidth)) {
470-
sizeWatch();
471-
sizeWatch = null;
469+
sizeWatch = $scope.$watch(angular.noop, function() {
470+
if (!updaterScheduled) {
471+
updaterScheduled = true;
472+
$scope.$$postDigest(function() {
473+
updaterScheduled = false;
474+
if (updateIfVisible(calculateContainerWidth())) {
475+
sizeWatch();
476+
sizeWatch = null;
477+
}
478+
});
472479
}
473480
});
474481
}

0 commit comments

Comments
 (0)