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