(animations)
| 3070 | } |
| 3071 | |
| 3072 | function groupAnimations(animations) { |
| 3073 | var preparedAnimations = []; |
| 3074 | var refLookup = {}; |
| 3075 | forEach(animations, function(animation, index) { |
| 3076 | var element = animation.element; |
| 3077 | var node = getDomNode(element); |
| 3078 | var event = animation.event; |
| 3079 | var enterOrMove = ['enter', 'move'].indexOf(event) >= 0; |
| 3080 | var anchorNodes = animation.structural ? getAnchorNodes(node) : []; |
| 3081 | |
| 3082 | if (anchorNodes.length) { |
| 3083 | var direction = enterOrMove ? 'to' : 'from'; |
| 3084 | |
| 3085 | forEach(anchorNodes, function(anchor) { |
| 3086 | var key = anchor.getAttribute(NG_ANIMATE_REF_ATTR); |
| 3087 | refLookup[key] = refLookup[key] || {}; |
| 3088 | refLookup[key][direction] = { |
| 3089 | animationID: index, |
| 3090 | element: jqLite(anchor) |
| 3091 | }; |
| 3092 | }); |
| 3093 | } else { |
| 3094 | preparedAnimations.push(animation); |
| 3095 | } |
| 3096 | }); |
| 3097 | |
| 3098 | var usedIndicesLookup = {}; |
| 3099 | var anchorGroups = {}; |
| 3100 | forEach(refLookup, function(operations, key) { |
| 3101 | var from = operations.from; |
| 3102 | var to = operations.to; |
| 3103 | |
| 3104 | if (!from || !to) { |
| 3105 | // only one of these is set therefore we can't have an |
| 3106 | // anchor animation since all three pieces are required |
| 3107 | var index = from ? from.animationID : to.animationID; |
| 3108 | var indexKey = index.toString(); |
| 3109 | if (!usedIndicesLookup[indexKey]) { |
| 3110 | usedIndicesLookup[indexKey] = true; |
| 3111 | preparedAnimations.push(animations[index]); |
| 3112 | } |
| 3113 | return; |
| 3114 | } |
| 3115 | |
| 3116 | var fromAnimation = animations[from.animationID]; |
| 3117 | var toAnimation = animations[to.animationID]; |
| 3118 | var lookupKey = from.animationID.toString(); |
| 3119 | if (!anchorGroups[lookupKey]) { |
| 3120 | var group = anchorGroups[lookupKey] = { |
| 3121 | structural: true, |
| 3122 | beforeStart: function() { |
| 3123 | fromAnimation.beforeStart(); |
| 3124 | toAnimation.beforeStart(); |
| 3125 | }, |
| 3126 | close: function() { |
| 3127 | fromAnimation.close(); |
| 3128 | toAnimation.close(); |
| 3129 | }, |
no test coverage detected