diff options
author | wout <wout@impinc.co.uk> | 2014-01-22 12:48:49 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-01-22 12:48:49 +0100 |
commit | b27d01e9f91bff6145170ebd46857cd703480fec (patch) | |
tree | aca9a0b30423ec4f7db769969ae5f3b25c7893df /src/doc.js | |
parent | df8db4b03df6740e47851907a4b901362634c50b (diff) | |
download | svg.js-b27d01e9f91bff6145170ebd46857cd703480fec.tar.gz svg.js-b27d01e9f91bff6145170ebd46857cd703480fec.zip |
Bumped to v0.33
Diffstat (limited to 'src/doc.js')
-rwxr-xr-x[-rw-r--r--] | src/doc.js | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/doc.js b/src/doc.js index 0a60f99..462fd84 100644..100755 --- a/src/doc.js +++ b/src/doc.js @@ -19,7 +19,11 @@ SVG.Doc = function(element) { /* create the <defs> node */ this._defs = new SVG.Defs + this._defs.parent = this this.node.appendChild(this._defs.node) + + /* turno of sub pixel offset by default */ + this.doSubPixelOffsetFix = false /* ensure correct rendering */ if (this.parent.nodeName != 'svg') @@ -61,11 +65,11 @@ SVG.extend(SVG.Doc, { element.parent.appendChild(element.node) /* after wrapping is done, fix sub-pixel offset */ - element.fixSubPixelOffset() + element.subPixelOffsetFix() /* make sure sub-pixel offset is fixed every time the window is resized */ SVG.on(window, 'resize', function() { - element.fixSubPixelOffset() + element.subPixelOffsetFix() }) }, 5) @@ -86,12 +90,23 @@ SVG.extend(SVG.Doc, { // Fix for possible sub-pixel offset. See: // https://bugzilla.mozilla.org/show_bug.cgi?id=608812 +, subPixelOffsetFix: function() { + if (this.doSubPixelOffsetFix) { + var pos = this.node.getScreenCTM() + + if (pos) + this + .style('left', (-pos.e % 1) + 'px') + .style('top', (-pos.f % 1) + 'px') + } + + return this + } + , fixSubPixelOffset: function() { - var pos = this.node.getScreenCTM() - - this - .style('left', (-pos.e % 1) + 'px') - .style('top', (-pos.f % 1) + 'px') + this.doSubPixelOffsetFix = true + + return this } })
\ No newline at end of file |