@@ -571,6 +571,13 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
571
571
return getDomNode ( nodeOrElmA ) === getDomNode ( nodeOrElmB ) ;
572
572
}
573
573
574
+ /**
575
+ * This fn returns false if any of the following is true:
576
+ * a) animations on the element or any parent are disabled
577
+ * b) a parent element has an ongoing structural animation, and animateChildren is false
578
+ * c) the element is not a child of the body
579
+ * d) the element is not a child of the $rootElement
580
+ */
574
581
function areAnimationsAllowed ( element , parentElement , event ) {
575
582
var bodyElement = jqLite ( $document [ 0 ] . body ) ;
576
583
var bodyElementDetected = isMatchingElement ( element , bodyElement ) || element [ 0 ] . nodeName === 'HTML' ;
@@ -579,6 +586,11 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
579
586
var animateChildren ;
580
587
var elementDisabled = disabledElementsLookup . get ( getDomNode ( element ) ) ;
581
588
589
+ if ( elementDisabled === true ) {
590
+ // If animations on the element have been disabled explicitly, no need to traverse the parents
591
+ return false ;
592
+ }
593
+
582
594
var parentHost = element . data ( NG_ANIMATE_PIN_DATA ) ;
583
595
if ( parentHost ) {
584
596
parentElement = parentHost ;
@@ -604,10 +616,12 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
604
616
if ( ! parentAnimationDetected ) {
605
617
var parentElementDisabled = disabledElementsLookup . get ( parentNode ) ;
606
618
607
- // disable animations if the user hasn't explicitly enabled animations on the
608
- // current element
609
619
if ( parentElementDisabled === true && elementDisabled !== false ) {
620
+ // disable animations if the user hasn't explicitly enabled animations on the
621
+ // current element
610
622
elementDisabled = true ;
623
+ // element is disabled via parent element, no need to check anything else
624
+ break ;
611
625
} else if ( parentElementDisabled === false ) {
612
626
elementDisabled = false ;
613
627
}
@@ -624,26 +638,29 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
624
638
// there is no need to continue traversing at this point
625
639
if ( parentAnimationDetected && animateChildren === false ) break ;
626
640
627
- if ( ! rootElementDetected ) {
628
- // angular doesn't want to attempt to animate elements outside of the application
629
- // therefore we need to ensure that the rootElement is an ancestor of the current element
630
- rootElementDetected = isMatchingElement ( parentElement , $rootElement ) ;
631
- if ( ! rootElementDetected ) {
632
- parentHost = parentElement . data ( NG_ANIMATE_PIN_DATA ) ;
633
- if ( parentHost ) {
634
- // The pin target element becomes the parent element
635
- parentElement = parentHost ;
636
- rootElementDetected = isMatchingElement ( parentElement , $rootElement ) ;
637
- }
641
+ if ( ! rootElementDetected && ! parentHost ) {
642
+ // If no rootElement is detected, and no parentHost has been found already,
643
+ // check if the parentElement is pinned to another element
644
+ parentHost = parentElement . data ( NG_ANIMATE_PIN_DATA ) ;
645
+ if ( parentHost ) {
646
+ // The pin target element becomes the parent element
647
+ parentElement = parentHost ;
648
+ rootElementDetected = isMatchingElement ( parentElement , $rootElement ) ;
638
649
}
639
650
}
640
651
641
652
if ( ! bodyElementDetected ) {
642
- // we also need to ensure that the element is or will be apart of the body element
653
+ // we also need to ensure that the element is or will be a part of the body element
643
654
// otherwise it is pointless to even issue an animation to be rendered
644
655
bodyElementDetected = isMatchingElement ( parentElement , bodyElement ) ;
645
656
}
646
657
658
+ if ( bodyElementDetected && rootElementDetected ) {
659
+ // If both body and root have been found, any other checks are pointless,
660
+ // as not animation data should live outside the application
661
+ break ;
662
+ }
663
+
647
664
parentElement = parentElement . parent ( ) ;
648
665
}
649
666
0 commit comments