From a72b8a7afb609b9a76c494d9123d78e5c40962bf Mon Sep 17 00:00:00 2001 From: wout Date: Sun, 23 Jun 2013 14:59:46 +0100 Subject: Added SVG.Number, reworked gradient system --- src/fx.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/fx.js') diff --git a/src/fx.js b/src/fx.js index e1063e3..eb563fa 100644 --- a/src/fx.js +++ b/src/fx.js @@ -250,6 +250,16 @@ SVG.extend(SVG.FX, { return this } + // Add animateable gradient update +, update: function(o) { + if (this.target instanceof SVG.Stop) { + if (o.opacity != null) this.attr('stop-opacity', o.opacity) + if (o.color != null) this.attr('stop-color', o.color) + if (o.offset != null) this.attr('offset', new SVG.Number(o.offset)) + } + + return this + } // Add callback for each keyframe , during: function(during) { this._during = during @@ -291,7 +301,10 @@ SVG.extend(SVG.FX, { /* unit recalculation */ SVG.regex.unit.test(o.to) ? - this._unit(o, pos) : + new SVG.Number(o.to) + .minus(new SVG.Number(o.from)) + .times(pos) + .plus(new SVG.Number(o.from)) : /* color recalculation */ o.to && (o.to.r || SVG.Color.test(o.to)) ? @@ -300,19 +313,6 @@ SVG.extend(SVG.FX, { /* for all other values wait until pos has reached 1 to return the final value */ pos < 1 ? o.from : o.to } - // Private: tween unit -, _unit: function(o, pos) { - var match, from - - /* convert FROM unit */ - match = SVG.regex.unit.exec(o.from.toString()) - from = parseFloat(match ? match[1] : 0) - - /* convert TO unit */ - match = SVG.regex.unit.exec(o.to) - - return (from + (parseFloat(match[1]) - from) * pos) + match[2] - } // Private: tween color , _color: function(o, pos) { var from, to -- cgit v1.2.3