MCPcopy
hub / github.com/angular-ui/ui-router / areAnimationsAllowed

Function areAnimationsAllowed

test/angular/1.4/angular-animate.js:2731–2814  ·  view source on GitHub ↗

* This fn returns false if any of the following is true: * a) animations on any parent element are disabled, and animations on the element aren't explicitly allowed * b) a parent element has an ongoing structural animation, and animateChildren is false * c) the element is not a child

(element, parentElement, event)

Source from the content-addressed store, hash-verified

2729 * d) the element is not a child of the $rootElement
2730 */
2731 function areAnimationsAllowed(element, parentElement, event) {
2732 var bodyElement = jqLite(rawDocument.body);
2733 var bodyElementDetected = isMatchingElement(element, bodyElement) || element[0].nodeName === 'HTML';
2734 var rootElementDetected = isMatchingElement(element, $rootElement);
2735 var parentAnimationDetected = false;
2736 var animateChildren;
2737 var elementDisabled = disabledElementsLookup.get(getDomNode(element));
2738
2739 var parentHost = jqLite.data(element[0], NG_ANIMATE_PIN_DATA);
2740 if (parentHost) {
2741 parentElement = parentHost;
2742 }
2743
2744 parentElement = getDomNode(parentElement);
2745
2746 while (parentElement) {
2747 if (!rootElementDetected) {
2748 // angular doesn't want to attempt to animate elements outside of the application
2749 // therefore we need to ensure that the rootElement is an ancestor of the current element
2750 rootElementDetected = isMatchingElement(parentElement, $rootElement);
2751 }
2752
2753 if (parentElement.nodeType !== ELEMENT_NODE) {
2754 // no point in inspecting the #document element
2755 break;
2756 }
2757
2758 var details = activeAnimationsLookup.get(parentElement) || {};
2759 // either an enter, leave or move animation will commence
2760 // therefore we can't allow any animations to take place
2761 // but if a parent animation is class-based then that's ok
2762 if (!parentAnimationDetected) {
2763 var parentElementDisabled = disabledElementsLookup.get(parentElement);
2764
2765 if (parentElementDisabled === true && elementDisabled !== false) {
2766 // disable animations if the user hasn't explicitly enabled animations on the
2767 // current element
2768 elementDisabled = true;
2769 // element is disabled via parent element, no need to check anything else
2770 break;
2771 } else if (parentElementDisabled === false) {
2772 elementDisabled = false;
2773 }
2774 parentAnimationDetected = details.structural;
2775 }
2776
2777 if (isUndefined(animateChildren) || animateChildren === true) {
2778 var value = jqLite.data(parentElement, NG_ANIMATE_CHILDREN_DATA);
2779 if (isDefined(value)) {
2780 animateChildren = value;
2781 }
2782 }
2783
2784 // there is no need to continue traversing at this point
2785 if (parentAnimationDetected && animateChildren === false) break;
2786
2787 if (!bodyElementDetected) {
2788 // we also need to ensure that the element is or will be a part of the body element

Callers 1

queueAnimationFunction · 0.70

Calls 4

isMatchingElementFunction · 0.70
getDomNodeFunction · 0.70
isUndefinedFunction · 0.70
isDefinedFunction · 0.70

Tested by

no test coverage detected