summaryrefslogtreecommitdiffstats
path: root/dist/svg.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-03-05 09:32:33 +0000
committerwout <wout@impinc.co.uk>2013-03-05 09:32:33 +0000
commit31e0a8f178185208aaf71702dadc1dbc8a6ff0eb (patch)
treee4f7dea76ae75fe4cc2207d2d96a27672b4e877a /dist/svg.js
parentca15876e17a1acce4909837af97d97995d0f5b23 (diff)
downloadsvg.js-31e0a8f178185208aaf71702dadc1dbc8a6ff0eb.tar.gz
svg.js-31e0a8f178185208aaf71702dadc1dbc8a6ff0eb.zip
Fix in animate().center()0.8
Diffstat (limited to 'dist/svg.js')
-rw-r--r--dist/svg.js111
1 files changed, 55 insertions, 56 deletions
diff --git a/dist/svg.js b/dist/svg.js
index d6c3039..32d5a8d 100644
--- a/dist/svg.js
+++ b/dist/svg.js
@@ -1,4 +1,4 @@
-/* svg.js v0.7-2-g028bf91 - svg viewbox bbox element container fx event group arrange defs mask pattern gradient doc shape wrap rect ellipse line poly path image text nested sugar - svgjs.com/license */
+/* svg.js v0.7-3-gca15876 - svg viewbox bbox element container fx event group arrange defs mask pattern gradient doc shape wrap rect ellipse line poly path image text nested sugar - svgjs.com/license */
(function() {
this.svg = function(element) {
@@ -126,6 +126,9 @@
, ry: 0
}
+ /* initialize style store */
+ this.style = {}
+
/* initialize transformation store with defaults */
this.trans = {
x: 0
@@ -552,11 +555,11 @@
duration = duration == null ? 1000 : duration
ease = ease || '<>'
- var akeys, tkeys, tvalues,
- element = this.target,
- fx = this,
- start = (new Date).getTime(),
- finish = start + duration
+ var akeys, tkeys, tvalues
+ , element = this.target
+ , fx = this
+ , start = (new Date).getTime()
+ , finish = start + duration
/* start animation */
this.interval = setInterval(function(){
@@ -625,9 +628,9 @@
}, duration > 10 ? 10 : duration)
return this
- },
+ }
// Add animatable attributes
- attr: function(a, v, n) {
+ , attr: function(a, v, n) {
if (typeof a == 'object')
for (var key in a)
this.attr(key, a[key])
@@ -636,55 +639,55 @@
this.attrs[a] = { from: this.target.attr(a), to: v }
return this;
- },
+ }
// Add animatable transformations
- transform: function(o) {
+ , transform: function(o) {
for (var key in o)
this.trans[key] = { from: this.target.trans[key], to: o[key] }
return this
- },
+ }
// Add animatable move
- move: function(x, y) {
+ , move: function(x, y) {
var box = this.target.bbox()
this._move = {
- x: { from: box.x, to: x },
- y: { from: box.y, to: y }
+ x: { from: box.x, to: x }
+ , y: { from: box.y, to: y }
}
return this
- },
+ }
// Add animatable size
- size: function(width, height) {
+ , size: function(width, height) {
var box = this.target.bbox()
this._size = {
- width: { from: box.width, to: width },
- height: { from: box.height, to: height }
+ width: { from: box.width, to: width }
+ , height: { from: box.height, to: height }
}
return this
- },
+ }
// Add animatable center
- center: function(x, y) {
+ , center: function(x, y) {
var box = this.target.bbox()
this._move = {
- x: { from: box.cx, to: x },
- y: { from: box.cy, to: y }
+ x: { from: box.cx, to: x - box.width / 2 }
+ , y: { from: box.cy, to: y - box.height / 2 }
}
return this
- },
+ }
// Callback after animation
- after: function(after) {
+ , after: function(after) {
this._after = after
return this
- },
+ }
// Stop running animation
- stop: function() {
+ , stop: function() {
/* stop current animation */
clearInterval(this.interval)
@@ -696,9 +699,9 @@
this._after = null
return this
- },
+ }
// Private: at position according to from and to
- _at: function(o, pos) {
+ , _at: function(o, pos) {
/* if a number, recalculate pos */
return typeof o.from == 'number' ?
o.from + (o.to - o.from) * pos :
@@ -709,9 +712,9 @@
/* for all other values wait until pos has reached 1 to return the final value */
pos < 1 ? o.from : o.to
- },
+ }
// Private: tween color
- _color: function(o, pos) {
+ , _color: function(o, pos) {
var from, to
/* convert FROM hex to rgb */
@@ -722,39 +725,39 @@
/* tween color and return hex */
return this._r2h({
- r: ~~(from.r + (to.r - from.r) * pos),
- g: ~~(from.g + (to.g - from.g) * pos),
- b: ~~(from.b + (to.b - from.b) * pos)
+ r: ~~(from.r + (to.r - from.r) * pos)
+ , g: ~~(from.g + (to.g - from.g) * pos)
+ , b: ~~(from.b + (to.b - from.b) * pos)
})
- },
+ }
// Private: convert hex to rgb object
- _h2r: function(hex) {
+ , _h2r: function(hex) {
/* parse full hex */
var match = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(this._fh(hex))
/* if the hex is successfully parsed, return it in rgb, otherwise return black */
return match ? {
- r: parseInt(match[1], 16),
- g: parseInt(match[2], 16),
- b: parseInt(match[3], 16)
+ r: parseInt(match[1], 16)
+ , g: parseInt(match[2], 16)
+ , b: parseInt(match[3], 16)
} : { r: 0, g: 0, b: 0 }
- },
+ }
// Private: convert rgb object to hex string
- _r2h: function(rgb) {
+ , _r2h: function(rgb) {
return '#' + this._c2h(rgb.r) + this._c2h(rgb.g) + this._c2h(rgb.b)
- },
+ }
// Private: convert component to hex
- _c2h: function(c) {
+ , _c2h: function(c) {
var hex = c.toString(16)
return hex.length == 1 ? '0' + hex : hex
- },
+ }
// Private: force potential 3-based hex to 6-based
- _fh: function(hex) {
+ , _fh: function(hex) {
return hex.length == 4 ?
[ '#',
- hex.substring(1, 2), hex.substring(1, 2),
- hex.substring(2, 3), hex.substring(2, 3),
- hex.substring(3, 4), hex.substring(3, 4)
+ hex.substring(1, 2), hex.substring(1, 2)
+ , hex.substring(2, 3), hex.substring(2, 3)
+ , hex.substring(3, 4), hex.substring(3, 4)
].join('') : hex
}
@@ -848,14 +851,6 @@
SVG.G.prototype = new SVG.Container
SVG.extend(SVG.G, {
- // Get defs
- defs: function() {
- return this.doc().defs()
- }
-
- })
-
- SVG.extend(SVG.G, {
// Move using translate
move: function(x, y) {
return this.transform({
@@ -863,7 +858,11 @@
, y: y
})
}
-
+ // Get defs
+ , defs: function() {
+ return this.doc().defs()
+ }
+
})
SVG.extend(SVG.Element, {