* @private
(target, values)
| 66 | * @private |
| 67 | */ |
| 68 | _createAnimations(target, values) { |
| 69 | const animatedProps = this._properties; |
| 70 | const animations = []; |
| 71 | const running = target.$animations || (target.$animations = {}); |
| 72 | const props = Object.keys(values); |
| 73 | const date = Date.now(); |
| 74 | let i; |
| 75 | |
| 76 | for (i = props.length - 1; i >= 0; --i) { |
| 77 | const prop = props[i]; |
| 78 | if (prop.charAt(0) === '$') { |
| 79 | continue; |
| 80 | } |
| 81 | |
| 82 | if (prop === 'options') { |
| 83 | animations.push(...this._animateOptions(target, values)); |
| 84 | continue; |
| 85 | } |
| 86 | const value = values[prop]; |
| 87 | let animation = running[prop]; |
| 88 | const cfg = animatedProps.get(prop); |
| 89 | |
| 90 | if (animation) { |
| 91 | if (cfg && animation.active()) { |
| 92 | // There is an existing active animation, let's update that |
| 93 | animation.update(cfg, value, date); |
| 94 | continue; |
| 95 | } else { |
| 96 | animation.cancel(); |
| 97 | } |
| 98 | } |
| 99 | if (!cfg || !cfg.duration) { |
| 100 | // not animated, set directly to new value |
| 101 | target[prop] = value; |
| 102 | continue; |
| 103 | } |
| 104 | |
| 105 | running[prop] = animation = new Animation(cfg, target, prop, value); |
| 106 | animations.push(animation); |
| 107 | } |
| 108 | return animations; |
| 109 | } |
| 110 | |
| 111 | |
| 112 | /** |
no test coverage detected