Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit afd4fc7

Browse files
committed
fix(tooltip, modal): add support for v1.4+ animations
1 parent 77f7a9f commit afd4fc7

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

src/modal/modal.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,14 @@ angular.module('mgcrea.ngStrap.modal', ['mgcrea.ngStrap.helpers.dimensions'])
161161
if(options.backdrop) {
162162
$animate.enter(backdropElement, bodyElement, null);
163163
}
164-
// Support v1.3+ $animate
165-
// https://github.com/angular/angular.js/commit/bf0f5502b1bbfddc5cdd2f138efd9188b8c652a9
166-
var promise = $animate.enter(modalElement, parent, after, enterAnimateCallback);
167-
if(promise && promise.then) promise.then(enterAnimateCallback);
164+
165+
// Support v1.2+ $animate
166+
// https://github.com/angular/angular.js/issues/11713
167+
if(angular.version.minor <= 2) {
168+
$animate.enter(modalElement, parent, after, enterAnimateCallback);
169+
} else {
170+
$animate.enter(modalElement, parent, after).then(enterAnimateCallback);
171+
}
168172

169173
$modal.$isShown = scope.$isShown = true;
170174
safeDigest(scope);
@@ -201,10 +205,14 @@ angular.module('mgcrea.ngStrap.modal', ['mgcrea.ngStrap.helpers.dimensions'])
201205
if(scope.$emit(options.prefixEvent + '.hide.before', $modal).defaultPrevented) {
202206
return;
203207
}
204-
var promise = $animate.leave(modalElement, leaveAnimateCallback);
205-
// Support v1.3+ $animate
206-
// https://github.com/angular/angular.js/commit/bf0f5502b1bbfddc5cdd2f138efd9188b8c652a9
207-
if(promise && promise.then) promise.then(leaveAnimateCallback);
208+
209+
// Support v1.2+ $animate
210+
// https://github.com/angular/angular.js/issues/11713
211+
if(angular.version.minor <= 2) {
212+
$animate.leave(modalElement, leaveAnimateCallback);
213+
} else {
214+
$animate.leave(modalElement).then(leaveAnimateCallback);
215+
}
208216

209217
if(options.backdrop) {
210218
$animate.leave(backdropElement);

src/tooltip/tooltip.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,13 @@ angular.module('mgcrea.ngStrap.tooltip', ['mgcrea.ngStrap.helpers.dimensions'])
227227
$tooltip.$applyPlacement();
228228

229229
// Once placed, animate it.
230-
// Support v1.3+ $animate
231-
// https://github.com/angular/angular.js/commit/bf0f5502b1bbfddc5cdd2f138efd9188b8c652a9
232-
var promise = $animate.enter(tipElement, parent, after, enterAnimateCallback);
233-
if(promise && promise.then) promise.then(enterAnimateCallback);
230+
// Support v1.2+ $animate
231+
// https://github.com/angular/angular.js/issues/11713
232+
if(angular.version.minor <= 2) {
233+
$animate.enter(tipElement, parent, after, enterAnimateCallback);
234+
} else {
235+
$animate.enter(tipElement, parent, after).then(enterAnimateCallback);
236+
}
234237
safeDigest(scope);
235238

236239
$$rAF(function () {
@@ -285,10 +288,13 @@ angular.module('mgcrea.ngStrap.tooltip', ['mgcrea.ngStrap.helpers.dimensions'])
285288
// in leaveAnimateCallback
286289
_tipToHide = tipElement;
287290

288-
// Support v1.3+ $animate
289-
// https://github.com/angular/angular.js/commit/bf0f5502b1bbfddc5cdd2f138efd9188b8c652a9
290-
var promise = $animate.leave(tipElement, leaveAnimateCallback);
291-
if(promise && promise.then) promise.then(leaveAnimateCallback);
291+
// Support v1.2+ $animate
292+
// https://github.com/angular/angular.js/issues/11713
293+
if(angular.version.minor <= 2) {
294+
$animate.leave(tipElement, leaveAnimateCallback);
295+
} else {
296+
$animate.leave(tipElement).then(leaveAnimateCallback);
297+
}
292298

293299
$tooltip.$isShown = scope.$isShown = false;
294300
safeDigest(scope);

0 commit comments

Comments
 (0)