Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 8f0b482

Browse files
committed
fix($animate): allow animations when pinned element is parent element
Previously, the animate queue would only detect pinned elements when they were the same element as the to-be-animated element. Related #12617 Closes #13466
1 parent 6428ed5 commit 8f0b482

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

src/ngAnimate/animateQueue.js

+1
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
586586
parentHost = parentElement.data(NG_ANIMATE_PIN_DATA);
587587
if (parentHost) {
588588
parentElement = parentHost;
589+
rootElementDetected = true;
589590
}
590591
}
591592
}

test/ngAnimate/animateSpec.js

+34-16
Original file line numberDiff line numberDiff line change
@@ -1448,28 +1448,46 @@ describe("animations", function() {
14481448
}));
14491449

14501450

1451-
it('should allow an element to be pinned elsewhere and still be available in animations',
1452-
inject(function($animate, $compile, $document, $rootElement, $rootScope) {
1451+
they('should animate an element inside a pinned element that is the $prop element',
1452+
['same', 'parent', 'grandparent'],
1453+
function(elementRelation) {
1454+
inject(function($animate, $compile, $document, $rootElement, $rootScope) {
14531455

1454-
var innerParent = jqLite('<div></div>');
1455-
jqLite($document[0].body).append(innerParent);
1456-
innerParent.append($rootElement);
1456+
var pinElement, animateElement;
14571457

1458-
var element = jqLite('<div></div>');
1459-
jqLite($document[0].body).append(element);
1458+
var innerParent = jqLite('<div></div>');
1459+
jqLite($document[0].body).append(innerParent);
1460+
innerParent.append($rootElement);
14601461

1461-
$animate.addClass(element, 'red');
1462-
$rootScope.$digest();
1463-
expect(capturedAnimation).toBeFalsy();
1462+
switch (elementRelation) {
1463+
case 'same':
1464+
pinElement = jqLite('<div id="animate"></div>');
1465+
break;
1466+
case 'parent':
1467+
pinElement = jqLite('<div><div id="animate"></div></div>');
1468+
break;
1469+
case 'grandparent':
1470+
pinElement = jqLite('<div><div><div id="animate"></div></div></div>');
1471+
break;
1472+
}
14641473

1465-
$animate.pin(element, $rootElement);
1474+
jqLite($document[0].body).append(pinElement);
1475+
animateElement = jqLite($document[0].getElementById('animate'));
14661476

1467-
$animate.addClass(element, 'blue');
1468-
$rootScope.$digest();
1469-
expect(capturedAnimation).toBeTruthy();
1477+
$animate.addClass(animateElement, 'red');
1478+
$rootScope.$digest();
1479+
expect(capturedAnimation).toBeFalsy();
14701480

1471-
dealoc(element);
1472-
}));
1481+
// Pin the element to the app root to enable animations
1482+
$animate.pin(pinElement, $rootElement);
1483+
1484+
$animate.addClass(animateElement, 'blue');
1485+
$rootScope.$digest();
1486+
expect(capturedAnimation).toBeTruthy();
1487+
1488+
dealoc(pinElement);
1489+
});
1490+
});
14731491

14741492
it('should adhere to the disabled state of the hosted parent when an element is pinned',
14751493
inject(function($animate, $compile, $document, $rootElement, $rootScope) {

0 commit comments

Comments
 (0)