Skip to content

Commit

Permalink
feat(modal): remove an unnecessary $digest
Browse files Browse the repository at this point in the history
Optimized opening of modals by causing one digest loop less: The modalBackdrop directive now schedules switching its animate flag using a $timeout which does not cause a digest loop. If we assume modalBackdrop is always followed by a modalWindow directive, then we are guaranteed a digest loop by modalWindow's $timeout, which will happen after modalBackdrop's $timeout.
  • Loading branch information
strille authored and wesleycho committed Mar 24, 2015
1 parent b076483 commit 7940fd0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ angular.module('ui.bootstrap.modal', [])

scope.animate = false;

//trigger CSS transitions
// schedule to trigger CSS transitions, but skip invoking apply immediately
// (modalWindow's $timeout will invoke an apply which is enough since modalWindow is added after modalBackdrop)
$timeout(function () {
scope.animate = true;
});
}, 0, false);
}
};
}])
Expand Down

0 comments on commit 7940fd0

Please sign in to comment.