123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- var AnimationWrap = function () {
- function AnimationWrap() {
- this._storage = [];
- this._elExistsMap = {};
- }
-
- AnimationWrap.prototype.add = function (el, target, duration, delay, easing) {
- if (this._elExistsMap[el.id]) {
- return false;
- }
- this._elExistsMap[el.id] = true;
- this._storage.push({
- el: el,
- target: target,
- duration: duration,
- delay: delay,
- easing: easing
- });
- return true;
- };
-
- AnimationWrap.prototype.finished = function (callback) {
- this._finishedCallback = callback;
- return this;
- };
-
- AnimationWrap.prototype.start = function () {
- var _this = this;
- var count = this._storage.length;
- var checkTerminate = function () {
- count--;
- if (count <= 0) {
-
- _this._storage.length = 0;
- _this._elExistsMap = {};
- _this._finishedCallback && _this._finishedCallback();
- }
- };
- for (var i = 0, len = this._storage.length; i < len; i++) {
- var item = this._storage[i];
- item.el.animateTo(item.target, {
- duration: item.duration,
- delay: item.delay,
- easing: item.easing,
- setToFinal: true,
- done: checkTerminate,
- aborted: checkTerminate
- });
- }
- return this;
- };
- return AnimationWrap;
- }();
- export function createWrap() {
- return new AnimationWrap();
- }
|