Commit e1fb048f authored by Dmitry Baranovskiy's avatar Dmitry Baranovskiy

Animation status fix

parent 951f8fb6
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -204,7 +204,7 @@
commaSpaces = /\s*,\s*/,
hsrg = {hs: 1, rg: 1},
p2s = /,?([achlmqrstvxz]),?/gi,
pathCommand = /([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?\s*,?\s*)+)/ig,
pathCommand = /([achlmrqstvz])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?\s*,?\s*)+)/ig,
tCommand = /([rstm])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?\s*,?\s*)+)/ig,
pathValues = /(-?\d*\.?\d*(?:e[\-+]?\d+)?)\s*,?\s*/ig,
radial_gradient = R._radial_gradient = /^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/,
......@@ -1005,7 +1005,7 @@
if (!pathString) {
return null;
}
var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, q: 4, s: 4, t: 2, v: 1, z: 0},
var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, z: 0},
data = [];
if (R.is(pathString, array) && R.is(pathString[0], array)) { // rough assumption
data = pathClone(pathString);
......@@ -3499,22 +3499,24 @@
**
> Parameters
**
- params (object) final attributes for the element, see also @Element.attr
- ms (number) number of milliseconds for animation to run
- element (object) element to sync with
- anim (object) animation to sync with
- params (object) #optional final attributes for the element, see also @Element.attr
- ms (number) #optional number of milliseconds for animation to run
- easing (string) #optional easing type. Accept on of @Raphael.easing_formulas or CSS format: `cubic‐bezier(XX, XX, XX, XX)`
- callback (function) #optional callback function. Will be called at the end of animation.
* or
- animation (object) animation object, see @Raphael.animation
- element (object) element to sync with
- anim (object) animation to sync with
- animation (object) #optional animation object, see @Raphael.animation
**
= (object) original element
\*/
elproto.animateWith = function (element, params, ms, easing, callback) {
// var a = R.animation(params, ms, easing, callback);
// status = element.status(anim);
// this.animate(a);
// this.status(a, status);
this.animate(params, ms, easing, callback);
return this;
elproto.animateWith = function (element, anim, params, ms, easing, callback) {
var a = params ? R.animation(params, ms, easing, callback) : anim;
status = element.status(anim);
this.animate(a);
return this.status(a, status * anim.ms / a.ms);
};
function CubicBezierAtTime(t, p1x, p1y, p2x, p2y, duration) {
var cx = 3 * p1x,
......@@ -3811,13 +3813,16 @@
totalOrigin: totalOrigin
};
animationElements.push(e);
if (status && !isInAnim) {
if (status && !isInAnim && !isInAnimSet) {
e.stop = true;
e.start = new Date - ms * status;
if (animationElements.length == 1) {
return animation();
}
}
if (isInAnimSet) {
e.start = new Date - e.ms * status;
}
animationElements.length == 1 && requestAnimFrame(animation);
} else {
isInAnim.initstatus = status;
......@@ -3842,6 +3847,9 @@
= (object) @Animation
\*/
R.animation = function (params, ms, easing, callback) {
if (params instanceof Animation) {
return params;
}
if (R.is(easing, "function") || !easing) {
callback = callback || easing || null;
easing = null;
......@@ -3949,7 +3957,10 @@
if (anim) {
return e.status;
}
out.push({anim: e.anim, status: e.status});
out.push({
anim: e.anim,
status: e.status
});
}
}
if (anim) {
......@@ -4200,7 +4211,7 @@
!--len && callback.call(set);
});
easing = R.is(easing, string) ? easing : collector;
var anim = params instanceof Animation ? params : R.animation(params, ms, easing, collector);
var anim = R.animation(params, ms, easing, collector);
item = this.items[--i].animate(anim);
while (i--) {
this.items[i] && !this.items[i].removed && this.items[i].animateWith(item, anim);
......
......@@ -362,7 +362,7 @@
commaSpaces = /\s*,\s*/,
hsrg = {hs: 1, rg: 1},
p2s = /,?([achlmqrstvxz]),?/gi,
pathCommand = /([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?\s*,?\s*)+)/ig,
pathCommand = /([achlmrqstvz])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?\s*,?\s*)+)/ig,
tCommand = /([rstm])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?\s*,?\s*)+)/ig,
pathValues = /(-?\d*\.?\d*(?:e[\-+]?\d+)?)\s*,?\s*/ig,
radial_gradient = R._radial_gradient = /^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/,
......@@ -884,7 +884,7 @@
if (!pathString) {
return null;
}
var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, q: 4, s: 4, t: 2, v: 1, z: 0},
var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, z: 0},
data = [];
if (R.is(pathString, array) && R.is(pathString[0], array)) { // rough assumption
data = pathClone(pathString);
......@@ -2559,13 +2559,11 @@
return color > 255 ? 255 : color < 0 ? 0 : color;
};
elproto.animateWith = function (element, params, ms, easing, callback) {
// var a = R.animation(params, ms, easing, callback);
// status = element.status(anim);
// this.animate(a);
// this.status(a, status);
this.animate(params, ms, easing, callback);
return this;
elproto.animateWith = function (element, anim, params, ms, easing, callback) {
var a = params ? R.animation(params, ms, easing, callback) : anim;
status = element.status(anim);
this.animate(a);
return this.status(a, status * anim.ms / a.ms);
};
function CubicBezierAtTime(t, p1x, p1y, p2x, p2y, duration) {
var cx = 3 * p1x,
......@@ -2840,13 +2838,16 @@
totalOrigin: totalOrigin
};
animationElements.push(e);
if (status && !isInAnim) {
if (status && !isInAnim && !isInAnimSet) {
e.stop = true;
e.start = new Date - ms * status;
if (animationElements.length == 1) {
return animation();
}
}
if (isInAnimSet) {
e.start = new Date - e.ms * status;
}
animationElements.length == 1 && requestAnimFrame(animation);
} else {
isInAnim.initstatus = status;
......@@ -2856,6 +2857,9 @@
}
R.animation = function (params, ms, easing, callback) {
if (params instanceof Animation) {
return params;
}
if (R.is(easing, "function") || !easing) {
callback = callback || easing || null;
easing = null;
......@@ -2912,7 +2916,10 @@
if (anim) {
return e.status;
}
out.push({anim: e.anim, status: e.status});
out.push({
anim: e.anim,
status: e.status
});
}
}
if (anim) {
......@@ -3078,7 +3085,7 @@
!--len && callback.call(set);
});
easing = R.is(easing, string) ? easing : collector;
var anim = params instanceof Animation ? params : R.animation(params, ms, easing, collector);
var anim = R.animation(params, ms, easing, collector);
item = this.items[--i].animate(anim);
while (i--) {
this.items[i] && !this.items[i].removed && this.items[i].animateWith(item, anim);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment