aboutsummaryrefslogtreecommitdiffstats
path: root/src/textpath.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-08-25 10:33:35 +0200
committerwout <wout@impinc.co.uk>2014-08-25 10:33:35 +0200
commit7b8e6f1d5afe2472cd1245f9bb73b6d59238e541 (patch)
tree51f85409971875f642315b8cd3b67d8bbf0cc504 /src/textpath.js
parent7c195432d30bf2c179d2f5c2682b85d76ef9458b (diff)
downloadsvg.js-7b8e6f1d5afe2472cd1245f9bb73b6d59238e541.tar.gz
svg.js-7b8e6f1d5afe2472cd1245f9bb73b6d59238e541.zip
Removed internal references from SVG.Text
Diffstat (limited to 'src/textpath.js')
-rwxr-xr-xsrc/textpath.js43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/textpath.js b/src/textpath.js
index 0ee9d77..03dfbee 100755
--- a/src/textpath.js
+++ b/src/textpath.js
@@ -12,31 +12,42 @@ SVG.TextPath = SVG.invent({
, construct: {
// Create path for text to run on
path: function(d) {
- /* create textPath element */
- this.textPath = new SVG.TextPath
+ // create textPath element
+ var path = new SVG.TextPath
+ , track = this.doc().defs().path(d)
- /* move lines to textpath */
- while(this.node.hasChildNodes())
- this.textPath.node.appendChild(this.node.firstChild)
+ // move lines to textpath
+ while (this.node.hasChildNodes())
+ path.node.appendChild(this.node.firstChild)
- /* add textPath element as child node */
- this.node.appendChild(this.textPath.node)
+ // add textPath element as child node
+ this.node.appendChild(path.node)
- /* create path in defs */
- this.track = this.doc().defs().path(d)
-
- /* create circular reference */
- this.textPath.parent = this
-
- /* link textPath to path and add content */
- this.textPath.attr('href', '#' + this.track, SVG.xlink)
+ // link textPath to path and add content
+ path.attr('href', '#' + track, SVG.xlink)
return this
}
// Plot path if any
, plot: function(d) {
- if (this.track) this.track.plot(d)
+ var track = this.track()
+
+ if (track)
+ track.plot(d)
+
return this
}
+ // Get the path track element
+ , track: function() {
+ var path = this.textPath()
+
+ if (path)
+ return path.reference('href')
+ }
+ // Get the textPath child
+ , textPath: function() {
+ if (this.node.firstChild && this.node.firstChild.nodeName == 'textPath')
+ return SVG.adopt(this.node.firstChild)
+ }
}
}) \ No newline at end of file