Remove usage of d3_array for efficiency.

This avoids unnecessarily creating a new array for every touch event.
This commit is contained in:
Jason Davies 2011-05-12 10:10:04 +01:00
Родитель a5f140709c
Коммит 1bb3e9b025
4 изменённых файлов: 20 добавлений и 10 удалений

13
d3.js поставляемый
Просмотреть файл

@ -3183,7 +3183,11 @@ function d3_svg_mousePoints(container, events) {
d3_mouse_bug44083 = !(ctm.f || ctm.e);
svg.remove();
}
return events.map(function(e) {
var i = -1,
n = events.length,
points = [];
while (++i < n) {
var e = events[i];
if (d3_mouse_bug44083) {
point.x = e.pageX;
point.y = e.pageY;
@ -3192,13 +3196,14 @@ function d3_svg_mousePoints(container, events) {
point.y = e.clientY;
}
point = point.matrixTransform(container.getScreenCTM().inverse());
return [point.x, point.y];
});
points.push([point.x, point.y]);
}
return points;
};
d3.svg.touches = function(container) {
var touches = d3.event.touches;
return touches && touches.length
? d3_svg_mousePoints(container, d3_array(touches)) : [];
? d3_svg_mousePoints(container, touches) : [];
};
d3.svg.symbol = function() {
var type = d3_svg_symbolType,

4
d3.min.js поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -17,7 +17,11 @@ function d3_svg_mousePoints(container, events) {
d3_mouse_bug44083 = !(ctm.f || ctm.e);
svg.remove();
}
return events.map(function(e) {
var i = -1,
n = events.length,
points = [];
while (++i < n) {
var e = events[i];
if (d3_mouse_bug44083) {
point.x = e.pageX;
point.y = e.pageY;
@ -26,6 +30,7 @@ function d3_svg_mousePoints(container, events) {
point.y = e.clientY;
}
point = point.matrixTransform(container.getScreenCTM().inverse());
return [point.x, point.y];
});
points.push([point.x, point.y]);
}
return points;
};

Просмотреть файл

@ -1,5 +1,5 @@
d3.svg.touches = function(container) {
var touches = d3.event.touches;
return touches && touches.length
? d3_svg_mousePoints(container, d3_array(touches)) : [];
? d3_svg_mousePoints(container, touches) : [];
};