Created
May 14, 2013 22:21
-
-
Save jfirebaugh/5580143 to your computer and use it in GitHub Desktop.
Poor performance when transforming SVG element on Firefox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<body> | |
<script src="http://d3js.org/d3.v3.js"></script> | |
<div id="container"> | |
</div> | |
<script> | |
var width = 1000, | |
height = 1000; | |
var container = d3.select("#container") | |
.call(d3.behavior.zoom() | |
.on('zoom', function() { | |
var tx = 'translate3d(' + | |
d3.event.translate[0] + 'px,' + | |
d3.event.translate[1] + 'px, 0)'; | |
svg.style('-webkit-transform', tx); | |
svg.style('transform', tx); | |
})); | |
var svg = container.append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
var data = []; | |
for (var i = 0; i < 1000; i += 5) | |
for (var j = 0; j < 1000; j += 5) | |
data.push([i, j]); | |
var rects = svg.selectAll('rect') | |
.data(data) | |
.enter().append('rect') | |
.attr('x', function(d) { return d[0]; }) | |
.attr('y', function(d) { return d[1]; }) | |
.attr('width', 4) | |
.attr('height', 4); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment