Improve perf with some benchmarking.

Re translate change see http://jsperf.com/coerce-vs-join-array
This commit is contained in:
Tom MacWright
2013-02-07 22:55:44 -05:00
parent 054ecae5c9
commit a773aaaab4
5 changed files with 9 additions and 7 deletions
+5 -3
View File
@@ -7,18 +7,20 @@
Only one of these elements can have the :hover pseudo-class, but all of them will
have the .hover class.
*/
iD.behavior.Hover = function () {
iD.behavior.Hover = function() {
var hover = function(selection) {
selection.classed('behavior-hover', true);
selection.on('mouseover.hover', function () {
function mouseover() {
var datum = d3.event.target.__data__;
if (datum) {
selection.selectAll('*')
.filter(function (d) { return d === datum; })
.classed('hover', true);
}
});
}
selection.on('mouseover.hover', mouseover);
selection.on('mouseout.hover', function () {
selection.selectAll('.hover')
+1 -1
View File
@@ -12,7 +12,7 @@ _.extend(iD.Node.prototype, {
type: "node",
extent: function() {
return iD.geo.Extent(this.loc);
return new iD.geo.Extent(this.loc);
},
geometry: function(graph) {
+1 -1
View File
@@ -301,7 +301,7 @@ iD.Map = function(context) {
map.extent = function(_) {
if (!arguments.length) {
return iD.geo.Extent(projection.invert([0, dimensions[1]]),
return new iD.geo.Extent(projection.invert([0, dimensions[1]]),
projection.invert([dimensions[0], 0]));
} else {
var extent = iD.geo.Extent(_),
+1 -1
View File
@@ -7,7 +7,7 @@ iD.svg = {
PointTransform: function(projection) {
return function(entity) {
return 'translate(' + projection(entity.loc) + ')';
return 'translate(' + projection(entity.loc).join(',') + ')';
};
},
+1 -1
View File
@@ -22,7 +22,7 @@ iD.ui.lasso = function() {
// top-left
function topLeft(d) {
return 'translate(' +
[Math.min(d[0][0], d[1][0]), Math.min(d[0][1], d[1][1])] + ')';
[Math.min(d[0][0], d[1][0]), Math.min(d[0][1], d[1][1])].join(',') + ')';
}
function width(d) { return Math.abs(d[0][0] - d[1][0]); }