summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2012-12-23 11:52:07 +0100
committerwout <wout@impinc.co.uk>2012-12-23 11:52:07 +0100
commit1ae730fec364f70d4541f38930929607dc2a31ac (patch)
tree16630efcc4b3ce6a09454681141518a05e4acde4 /src
parent70394584bec59f0b01998b9b54479bb913b0b32a (diff)
downloadsvg.js-1ae730fec364f70d4541f38930929607dc2a31ac.tar.gz
svg.js-1ae730fec364f70d4541f38930929607dc2a31ac.zip
Fixed a bug in safari prevending correct dy on tspans
Diffstat (limited to 'src')
-rw-r--r--src/arrange.js10
-rw-r--r--src/clip.js2
-rw-r--r--src/container.js24
-rw-r--r--src/doc.js9
-rw-r--r--src/element.js5
5 files changed, 36 insertions, 14 deletions
diff --git a/src/arrange.js b/src/arrange.js
index b5dc41a..001da75 100644
--- a/src/arrange.js
+++ b/src/arrange.js
@@ -4,20 +4,20 @@ SVG.extend(SVG.Element, {
// get all siblings, including me
siblings: function() {
- return this.mother().children();
+ return this.parent.children();
},
// send given element one step forwards
forward: function() {
var i = this.siblings().indexOf(this);
- this.mother().remove(this).add(this, i + 1);
+ this.parent.remove(this).add(this, i + 1);
return this;
},
// send given element one step backwards
backward: function() {
- var i, p = this.mother().levelDefs();
+ var i, p = this.parent.level();
i = this.siblings().indexOf(this);
@@ -29,14 +29,14 @@ SVG.extend(SVG.Element, {
// send given element all the way to the front
front: function() {
- this.mother().remove(this).add(this);
+ this.parent.remove(this).add(this);
return this;
},
// send given element all the way to the back
back: function() {
- var i, p = this.mother().levelDefs();
+ var i, p = this.parent.level();
i = this.siblings().indexOf(this);
diff --git a/src/clip.js b/src/clip.js
index f4fba45..9b106b4 100644
--- a/src/clip.js
+++ b/src/clip.js
@@ -19,7 +19,7 @@ SVG.extend(SVG.Element, {
// clip element using another element
clip: function(b) {
- var p = this.mother().defs().clip();
+ var p = this.parent.defs().clip();
b(p);
return this.clipTo(p);
diff --git a/src/container.js b/src/container.js
index f45bd6c..c5658ee 100644
--- a/src/container.js
+++ b/src/container.js
@@ -44,7 +44,7 @@ SVG.Container = {
return this._defs;
},
- levelDefs: function() {
+ level: function() {
var d = this.defs();
this.remove(d).add(d, 0);
@@ -103,6 +103,28 @@ SVG.Container = {
gradient: function(t, b) {
return this.defs().gradient(t, b);
+ },
+
+ // hack for safari preventing text to be rendered in one line,
+ // basically it sets the position of the svg node to absolute
+ // when the dom is loaded, and resets it to relative a few ms later.
+ stage: function() {
+ if (document.readyState !== 'complete') {
+ var r, e = this;
+
+ r = function() {
+ if (document.readyState === 'complete') {
+ e.node.style.position = 'absolute';
+ setTimeout(function() { e.node.style.position = 'relative'; }, 5);
+ } else {
+ setTimeout(r, 10);
+ }
+ };
+
+ r();
+ }
+
+ return this;
}
}; \ No newline at end of file
diff --git a/src/doc.js b/src/doc.js
index ead1116..0322e86 100644
--- a/src/doc.js
+++ b/src/doc.js
@@ -8,16 +8,21 @@ SVG.Doc = function Doc(e) {
// set
this.
- attr({ xmlns: SVG.ns, version: '1.1' }).
+ attr({ xmlns: SVG.ns, version: '1.1', style: 'position:relative;' }).
attr('xlink', SVG.xlink, SVG.ns).
size(e.offsetWidth, e.offsetHeight).
defs();
e.appendChild(this.node);
+
+ // ensure
+ this.stage();
};
// inherit from SVG.Element
SVG.Doc.prototype = new SVG.Element();
// include the container object
-SVG.extend(SVG.Doc, SVG.Container); \ No newline at end of file
+SVG.extend(SVG.Doc, SVG.Container);
+
+
diff --git a/src/element.js b/src/element.js
index 5664f46..ff3ad37 100644
--- a/src/element.js
+++ b/src/element.js
@@ -28,11 +28,6 @@ SVG.extend(SVG.Element, {
parentDoc: function() {
return this._parent(SVG.Doc);
},
-
- // get parent svg wrapper
- mother: function() {
- return this.parentDoc();
- },
// set svg element attribute
attr: function(a, v, n) {