| 26 | |
| 27 | export default class Animation { |
| 28 | constructor(cfg, target, prop, to) { |
| 29 | const currentValue = target[prop]; |
| 30 | |
| 31 | to = resolve([cfg.to, to, currentValue, cfg.from]); |
| 32 | const from = resolve([cfg.from, currentValue, to]); |
| 33 | |
| 34 | this._active = true; |
| 35 | this._fn = cfg.fn || interpolators[cfg.type || typeof from]; |
| 36 | this._easing = effects[cfg.easing] || effects.linear; |
| 37 | this._start = Math.floor(Date.now() + (cfg.delay || 0)); |
| 38 | this._duration = this._total = Math.floor(cfg.duration); |
| 39 | this._loop = !!cfg.loop; |
| 40 | this._target = target; |
| 41 | this._prop = prop; |
| 42 | this._from = from; |
| 43 | this._to = to; |
| 44 | this._promises = undefined; |
| 45 | } |
| 46 | |
| 47 | active() { |
| 48 | return this._active; |