Added callback to animation

master
Dmitry Baranovskiy 2013-08-16 12:56:19 +10:00
parent 583bb2a37d
commit f5a8d501e3
4 changed files with 44 additions and 18 deletions

12
mina.js
View File

@ -25,6 +25,11 @@ window.mina = (function () {
return a instanceof Array ||
Object.prototype.toString.call(a) == "[object Array]";
},
idgen = 0,
idprefix = "M" + (+new Date).toString(36),
ID = function () {
return idprefix + (idgen++).toString(36);
},
diff = function (a, b, A, B) {
if (isArray(a)) {
res = [];
@ -79,17 +84,22 @@ window.mina = (function () {
if (isArray(a.start)) {
res = [];
for (var j = 0, jj = a.start.length; j < jj; j++) {
res[j] = a.start[j] + (a.end[j] - a.start[j]) * a.easing(a.s);
res[j] = a.start[j] +
(a.end[j] - a.start[j]) * a.easing(a.s);
}
} else {
res = a.start + (a.end - a.start) * a.easing(a.s);
}
a.set(res);
if (a.s == 1 && typeof eve != "undefined") {
eve("mina.finish." + a.id, a);
}
}
animations.length && requestAnimFrame(frame);
},
mina = function (a, A, b, B, get, set, easing) {
var anim = {
id: ID(),
start: a,
end: A,
b: b,

4
savage-min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -428,6 +428,11 @@ window.mina = (function () {
return a instanceof Array ||
Object.prototype.toString.call(a) == "[object Array]";
},
idgen = 0,
idprefix = "M" + (+new Date).toString(36),
ID = function () {
return idprefix + (idgen++).toString(36);
},
diff = function (a, b, A, B) {
if (isArray(a)) {
res = [];
@ -482,17 +487,22 @@ window.mina = (function () {
if (isArray(a.start)) {
res = [];
for (var j = 0, jj = a.start.length; j < jj; j++) {
res[j] = a.start[j] + (a.end[j] - a.start[j]) * a.easing(a.s);
res[j] = a.start[j] +
(a.end[j] - a.start[j]) * a.easing(a.s);
}
} else {
res = a.start + (a.end - a.start) * a.easing(a.s);
}
a.set(res);
if (a.s == 1 && typeof eve != "undefined") {
eve("mina.finish." + a.id, a);
}
}
animations.length && requestAnimFrame(frame);
},
mina = function (a, A, b, B, get, set, easing) {
var anim = {
id: ID(),
start: a,
end: A,
b: b,
@ -2463,13 +2473,16 @@ function arrayFirstValue(arr) {
tkeys = tkeys.concat(to);
}
var now = mina.time(),
el = this;
return mina(fkeys, tkeys, now, now + ms, mina.time, function (val) {
var attr = {};
for (var key in keys) if (keys[has](key)) {
attr[key] = keys[key](val);
}
el.attr(attr);
el = this,
anim = mina(fkeys, tkeys, now, now + ms, mina.time, function (val) {
var attr = {};
for (var key in keys) if (keys[has](key)) {
attr[key] = keys[key](val);
}
el.attr(attr);
});
callback && eve.once("mina.finish." + anim.id, function () {
callback.call(el);
});
};
}(Element.prototype));

17
svg.js
View File

@ -1587,13 +1587,16 @@ function arrayFirstValue(arr) {
tkeys = tkeys.concat(to);
}
var now = mina.time(),
el = this;
return mina(fkeys, tkeys, now, now + ms, mina.time, function (val) {
var attr = {};
for (var key in keys) if (keys[has](key)) {
attr[key] = keys[key](val);
}
el.attr(attr);
el = this,
anim = mina(fkeys, tkeys, now, now + ms, mina.time, function (val) {
var attr = {};
for (var key in keys) if (keys[has](key)) {
attr[key] = keys[key](val);
}
el.attr(attr);
});
callback && eve.once("mina.finish." + anim.id, function () {
callback.call(el);
});
};
}(Element.prototype));