return this._active;
}
+ update(cfg, to, date) {
+ const me = this;
+ if (me._active) {
+ const currentValue = me._target[me._prop];
+ const elapsed = date - me._start;
+ const remain = me._duration - elapsed;
+ me._start = date;
+ me._duration = Math.floor(Math.max(remain, cfg.duration));
+ me._to = resolve([cfg.to, to, currentValue, cfg.from]);
+ me._from = resolve([cfg.from, currentValue, to]);
+ }
+ }
+
cancel() {
const me = this;
if (me._active) {
const animations = [];
const running = target.$animations || (target.$animations = {});
const props = Object.keys(values);
+ const date = Date.now();
let i;
for (i = props.length - 1; i >= 0; --i) {
}
const value = values[prop];
let animation = running[prop];
+ const cfg = animatedProps.get(prop);
+
if (animation) {
- animation.cancel();
+ if (cfg && animation.active()) {
+ // There is an existing active animation, let's update that
+ animation.update(cfg, value, date);
+ continue;
+ } else {
+ animation.cancel();
+ }
}
-
- const cfg = animatedProps.get(prop);
if (!cfg || !cfg.duration) {
// not animated, set directly to new value
target[prop] = value;