* Apply group transition animation from g1 to g2. * If no animatableModel, no animation.
(g1, g2, animatableModel, cb)
| 18045 | * If no animatableModel, no animation. |
| 18046 | */ |
| 18047 | function groupTransition(g1, g2, animatableModel, cb) { |
| 18048 | if (!g1 || !g2) { |
| 18049 | return; |
| 18050 | } |
| 18051 | |
| 18052 | function getElMap(g) { |
| 18053 | var elMap = {}; |
| 18054 | g.traverse(function (el) { |
| 18055 | if (!el.isGroup && el.anid) { |
| 18056 | elMap[el.anid] = el; |
| 18057 | } |
| 18058 | }); |
| 18059 | return elMap; |
| 18060 | } |
| 18061 | function getAnimatableProps(el) { |
| 18062 | var obj = { |
| 18063 | position: clone$1(el.position), |
| 18064 | rotation: el.rotation |
| 18065 | }; |
| 18066 | if (el.shape) { |
| 18067 | obj.shape = extend({}, el.shape); |
| 18068 | } |
| 18069 | return obj; |
| 18070 | } |
| 18071 | var elMap1 = getElMap(g1); |
| 18072 | |
| 18073 | g2.traverse(function (el) { |
| 18074 | if (!el.isGroup && el.anid) { |
| 18075 | var oldEl = elMap1[el.anid]; |
| 18076 | if (oldEl) { |
| 18077 | var newProp = getAnimatableProps(el); |
| 18078 | el.attr(getAnimatableProps(oldEl)); |
| 18079 | updateProps(el, newProp, animatableModel, el.dataIndex); |
| 18080 | } |
| 18081 | // else { |
| 18082 | // if (el.previousProps) { |
| 18083 | // graphic.updateProps |
| 18084 | // } |
| 18085 | // } |
| 18086 | } |
| 18087 | }); |
| 18088 | } |
| 18089 | |
| 18090 | /** |
| 18091 | * @param {Array.<Array.<number>>} points Like: [[23, 44], [53, 66], ...] |
no test coverage detected