Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ad104a6

Browse files
committedNov 3, 2016
fixup! react to successful animations only
1 parent 27427cd commit ad104a6

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed
 

‎src/ng/directive/ngIf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ var ngIfDirective = ['$animate', '$compile', function($animate, $compile) {
115115
}
116116
if (block) {
117117
previousElements = getBlockNodes(block.clone);
118-
$animate.leave(previousElements).done(function() {
119-
previousElements = null;
118+
$animate.leave(previousElements).done(function(response) {
119+
if (response !== false) previousElements = null;
120120
});
121121
block = null;
122122
}

‎src/ng/directive/ngInclude.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,19 @@ var ngIncludeDirective = ['$templateRequest', '$anchorScroll', '$animate',
214214
currentScope = null;
215215
}
216216
if (currentElement) {
217-
$animate.leave(currentElement).done(function() {
218-
previousElement = null;
217+
$animate.leave(currentElement).done(function(response) {
218+
if (response !== false) previousElement = null;
219219
});
220220
previousElement = currentElement;
221221
currentElement = null;
222222
}
223223
};
224224

225225
scope.$watch(srcExp, function ngIncludeWatchAction(src) {
226-
var afterAnimation = function() {
227-
if (isDefined(autoScrollExp) && (!autoScrollExp || scope.$eval(autoScrollExp))) {
228-
$anchorScroll();
226+
var afterAnimation = function(response) {
227+
if (response !== false && isDefined(autoScrollExp) &&
228+
(!autoScrollExp || scope.$eval(autoScrollExp))) {
229+
$anchorScroll();
229230
}
230231
};
231232
var thisChangeId = ++changeCounter;

‎src/ng/directive/ngSwitch.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,15 @@ var ngSwitchDirective = ['$animate', '$compile', function($animate, $compile) {
153153
selectedScopes = [];
154154

155155
var spliceFactory = function(array, index) {
156-
return function() {
157-
array.splice(index, 1);
156+
return function(response) {
157+
if (response !== false) array.splice(index, 1);
158158
};
159159
};
160160

161161
scope.$watch(watchExpr, function ngSwitchWatchAction(value) {
162162
var i, ii;
163163

164-
// Start from the end, in case the array is modified during the loop
165-
for (i = previousLeaveAnimations.length - 1; i >= 0; i--) {
164+
for (i = 0, ii = previousLeaveAnimations.length; i < ii; ++i) {
166165
$animate.cancel(previousLeaveAnimations[i]);
167166
}
168167
previousLeaveAnimations.length = 0;

‎src/ngRoute/directive/ngView.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ function ngViewFactory($route, $anchorScroll, $animate) {
207207
}
208208
if (currentElement) {
209209
previousLeaveAnimation = $animate.leave(currentElement);
210-
previousLeaveAnimation.done(function() {
211-
previousLeaveAnimation = null;
210+
previousLeaveAnimation.done(function(response) {
211+
if (response !== false) previousLeaveAnimation = null;
212212
});
213213
currentElement = null;
214214
}
@@ -229,8 +229,8 @@ function ngViewFactory($route, $anchorScroll, $animate) {
229229
// function is called before linking the content, which would apply child
230230
// directives to non existing elements.
231231
var clone = $transclude(newScope, function(clone) {
232-
$animate.enter(clone, null, currentElement || $element).done(function onNgViewEnter() {
233-
if (angular.isDefined(autoScrollExp)
232+
$animate.enter(clone, null, currentElement || $element).done(function onNgViewEnter(response) {
233+
if (response !== false && angular.isDefined(autoScrollExp)
234234
&& (!autoScrollExp || scope.$eval(autoScrollExp))) {
235235
$anchorScroll();
236236
}

0 commit comments

Comments
 (0)
This repository has been archived.