summaryrefslogtreecommitdiffstats
path: root/src/doc.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-02-14 22:25:12 +0100
committerwout <wout@impinc.co.uk>2014-02-14 22:25:12 +0100
commit8f9ccb16300142307b8ed6aed46c2a4984545600 (patch)
tree77040e5aa3802c7890d67aa0a62cdff432c2359f /src/doc.js
parenta7d61df3e8e065599c42752d60bb2f0190395080 (diff)
downloadsvg.js-8f9ccb16300142307b8ed6aed46c2a4984545600.tar.gz
svg.js-8f9ccb16300142307b8ed6aed46c2a4984545600.zip
Completely reworked `SVG.Text`, `SVG.TSpan` and `SVG.PathArray` and bumped to 1.0.0-rc.5
Diffstat (limited to 'src/doc.js')
-rwxr-xr-xsrc/doc.js65
1 files changed, 18 insertions, 47 deletions
diff --git a/src/doc.js b/src/doc.js
index 5129dd9..a10bffe 100755
--- a/src/doc.js
+++ b/src/doc.js
@@ -21,11 +21,11 @@ SVG.Doc = SVG.invent({
this._defs.parent = this
this.node.appendChild(this._defs.node)
- /* turno of sub pixel offset by default */
- this.doSubPixelOffsetFix = false
+ /* turn off sub pixel offset by default */
+ this.doSpof = false
/* ensure correct rendering */
- if (this.parent.nodeName != 'svg')
+ if (this.parent != this.node)
this.stage()
}
@@ -34,50 +34,20 @@ SVG.Doc = SVG.invent({
// Add class methods
, extend: {
- // 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 milliseconds later.
- // It also handles sub-pixel offset rendering properly.
+ /* enable drawing */
stage: function() {
- var check
- , element = this
- , wrapper = document.createElement('div')
+ var element = this
- /* set temporary wrapper to position relative */
- wrapper.style.cssText = 'position:relative;height:100%;'
+ /* insert element */
+ this.parent.appendChild(this.node)
- /* put element into wrapper */
- element.parent.appendChild(wrapper)
- wrapper.appendChild(element.node)
-
- /* check for dom:ready */
- check = function() {
- if (document.readyState === 'complete') {
- element.style('position:absolute;')
- setTimeout(function() {
- /* set position back to relative */
- element.style('position:relative;overflow:hidden;')
-
- /* remove temporary wrapper */
- element.parent.removeChild(element.node.parentNode)
- element.node.parentNode.removeChild(element.node)
- element.parent.appendChild(element.node)
-
- /* after wrapping is done, fix sub-pixel offset */
- element.subPixelOffsetFix()
-
- /* make sure sub-pixel offset is fixed every time the window is resized */
- SVG.on(window, 'resize', function() {
- element.subPixelOffsetFix()
- })
-
- }, 5)
- } else {
- setTimeout(check, 10)
- }
- }
-
- check()
+ /* fix sub-pixel offset */
+ element.spof()
+
+ /* make sure sub-pixel offset is fixed every time the window is resized */
+ SVG.on(window, 'resize', function() {
+ element.spof()
+ })
return this
}
@@ -89,8 +59,8 @@ SVG.Doc = SVG.invent({
// Fix for possible sub-pixel offset. See:
// https://bugzilla.mozilla.org/show_bug.cgi?id=608812
- , subPixelOffsetFix: function() {
- if (this.doSubPixelOffsetFix) {
+ , spof: function() {
+ if (this.doSpof) {
var pos = this.node.getScreenCTM()
if (pos)
@@ -102,8 +72,9 @@ SVG.Doc = SVG.invent({
return this
}
+ // Enable sub-pixel offset
, fixSubPixelOffset: function() {
- this.doSubPixelOffsetFix = true
+ this.doSpof = true
return this
}