mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 22:03:37 +02:00
Improve perf with some benchmarking.
Re translate change see http://jsperf.com/coerce-vs-join-array
This commit is contained in:
@@ -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
@@ -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) {
|
||||
|
||||
@@ -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
@@ -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
@@ -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]); }
|
||||
|
||||
Reference in New Issue
Block a user