MCPcopy Create free account
hub / github.com/angular-ui/ui-router / groupAnimations

Function groupAnimations

test/angular/1.5/angular-animate.js:3099–3180  ·  view source on GitHub ↗
(animations)

Source from the content-addressed store, hash-verified

3097 }
3098
3099 function groupAnimations(animations) {
3100 var preparedAnimations = [];
3101 var refLookup = {};
3102 forEach(animations, function(animation, index) {
3103 var element = animation.element;
3104 var node = getDomNode(element);
3105 var event = animation.event;
3106 var enterOrMove = ['enter', 'move'].indexOf(event) >= 0;
3107 var anchorNodes = animation.structural ? getAnchorNodes(node) : [];
3108
3109 if (anchorNodes.length) {
3110 var direction = enterOrMove ? 'to' : 'from';
3111
3112 forEach(anchorNodes, function(anchor) {
3113 var key = anchor.getAttribute(NG_ANIMATE_REF_ATTR);
3114 refLookup[key] = refLookup[key] || {};
3115 refLookup[key][direction] = {
3116 animationID: index,
3117 element: jqLite(anchor)
3118 };
3119 });
3120 } else {
3121 preparedAnimations.push(animation);
3122 }
3123 });
3124
3125 var usedIndicesLookup = {};
3126 var anchorGroups = {};
3127 forEach(refLookup, function(operations, key) {
3128 var from = operations.from;
3129 var to = operations.to;
3130
3131 if (!from || !to) {
3132 // only one of these is set therefore we can't have an
3133 // anchor animation since all three pieces are required
3134 var index = from ? from.animationID : to.animationID;
3135 var indexKey = index.toString();
3136 if (!usedIndicesLookup[indexKey]) {
3137 usedIndicesLookup[indexKey] = true;
3138 preparedAnimations.push(animations[index]);
3139 }
3140 return;
3141 }
3142
3143 var fromAnimation = animations[from.animationID];
3144 var toAnimation = animations[to.animationID];
3145 var lookupKey = from.animationID.toString();
3146 if (!anchorGroups[lookupKey]) {
3147 var group = anchorGroups[lookupKey] = {
3148 structural: true,
3149 beforeStart: function() {
3150 fromAnimation.beforeStart();
3151 toAnimation.beforeStart();
3152 },
3153 close: function() {
3154 fromAnimation.close();
3155 toAnimation.close();
3156 },

Callers 1

angular-animate.jsFile · 0.70

Calls 4

forEachFunction · 0.70
getDomNodeFunction · 0.70
getAnchorNodesFunction · 0.70
cssClassesIntersectionFunction · 0.70

Tested by

no test coverage detected