From 7e29cfe5373463e024d32d45978eeb0d527320a9 Mon Sep 17 00:00:00 2001 From: Dmitry Baranovskiy Date: Thu, 19 Sep 2013 09:30:40 +1000 Subject: [PATCH] Add new methods pause and resume to the animation object. Fix for bug #18 --- src/mina.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/mina.js b/src/mina.js index 3091cc3..b62fd73 100644 --- a/src/mina.js +++ b/src/mina.js @@ -76,6 +76,23 @@ var mina = (function (eve) { delete animations[a.id]; eve("mina.stop." + a.id, a); }, + pause = function () { + var a = this; + if (a.pdif) { + return; + } + delete animations[a.id]; + a.pdif = a.get() - a.b; + }, + resume = function () { + var a = this; + if (!a.pdif) { + return; + } + a.b = a.get() - a.pdif; + delete a.pdif; + animations[a.id] = a; + }, frame = function () { var len = 0; for (var i in animations) if (animations.hasOwnProperty(i)) { @@ -151,7 +168,9 @@ var mina = (function (eve) { status: sta, speed: speed, duration: duration, - stop: stopit + stop: stopit, + pause: pause, + resume: resume }; animations[anim.id] = anim; var len = 0, i; @@ -183,7 +202,7 @@ var mina = (function (eve) { = (object) See @mina \*/ mina.getById = function (id) { - return animations[anim.id] || null; + return animations[id] || null; }; /*\