aboutsummaryrefslogtreecommitdiffstats
path: root/src/textable.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-10-27 20:43:35 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-10-27 20:43:35 +0200
commit1c75fcaf02ceb144152d59557643c6fdd7264065 (patch)
tree5184af75f2fd27ca6b81c24a06b1676d17ca2c76 /src/textable.js
parentb1b776a710d0ce0a6259043b8ce0665e205195fa (diff)
downloadsvg.js-1c75fcaf02ceb144152d59557643c6fdd7264065.tar.gz
svg.js-1c75fcaf02ceb144152d59557643c6fdd7264065.zip
resolve circular references and make example working again
Diffstat (limited to 'src/textable.js')
-rw-r--r--src/textable.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/textable.js b/src/textable.js
new file mode 100644
index 0000000..f61f04a
--- /dev/null
+++ b/src/textable.js
@@ -0,0 +1,35 @@
+import Tspan from './Tspan.js'
+
+// Create plain text node
+export function plain (text) {
+ // clear if build mode is disabled
+ if (this._build === false) {
+ this.clear()
+ }
+
+ // create text node
+ this.node.appendChild(document.createTextNode(text))
+
+ return this
+}
+
+ // Create a tspan
+export function tspan (text) {
+ var tspan = new Tspan()
+
+ // clear if build mode is disabled
+ if (!this._build) {
+ this.clear()
+ }
+
+ // add new tspan
+ this.node.appendChild(tspan.node)
+
+ return tspan.text(text)
+}
+
+// FIXME: Does this also work for textpath?
+// Get length of text element
+export function length () {
+ return this.node.getComputedTextLength()
+}