summaryrefslogtreecommitdiffstats
path: root/src/spof.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-06-21 18:25:29 +0200
committerwout <wout@impinc.co.uk>2014-06-21 18:25:29 +0200
commit19b6fd4338246d1fd9ca4806e57c7aebcec63826 (patch)
tree3dd1d207de9f586f7e4d4cd36917e347ab022a9e /src/spof.js
parentbb0e6be2da0cea98c5303871c0be055f5f70d7a9 (diff)
downloadsvg.js-19b6fd4338246d1fd9ca4806e57c7aebcec63826.tar.gz
svg.js-19b6fd4338246d1fd9ca4806e57c7aebcec63826.zip
Removed all structural references
Diffstat (limited to 'src/spof.js')
-rw-r--r--src/spof.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/spof.js b/src/spof.js
new file mode 100644
index 0000000..cf4fe2f
--- /dev/null
+++ b/src/spof.js
@@ -0,0 +1,31 @@
+// Fix for possible sub-pixel offset. See:
+// https://bugzilla.mozilla.org/show_bug.cgi?id=608812
+SVG.extend(SVG.Doc, {
+ // Callback
+ spof: function() {
+ if (this.doSpof) {
+ var pos = this.node.getScreenCTM()
+
+ if (pos)
+ this
+ .style('left', (-pos.e % 1) + 'px')
+ .style('top', (-pos.f % 1) + 'px')
+ }
+
+ return this
+ }
+
+ // Sub-pixel offset enabler
+, fixSubPixelOffset: function() {
+ var self = this
+
+ // Enable spof
+ this.doSpof = true
+
+ // Make sure sub-pixel offset is fixed every time the window is resized
+ SVG.on(window, 'resize', function() { self.spof() })
+
+ return this.spof()
+ }
+
+}) \ No newline at end of file