Add touch support to `d3.svg.mouse`.

This doesn't quite seem like the right place for it, but it seems to work when
using "touchstart", "touchmove" and "touchend" handlers without any adverse
effects on "true" mouse event handlers.

See <http://www.jasondavies.com/apollonian-gasket/> to see an example of
combined touch/mouse handlers working with this change.
This commit is contained in:
Jason Davies 2011-05-10 22:42:16 +01:00
Родитель 7c518c547c
Коммит 5f2e430f25
3 изменённых файлов: 9 добавлений и 3 удалений

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

@ -3176,7 +3176,10 @@ d3.svg.mouse = function(container) {
d3_mouse_bug44083 = !(ctm.f || ctm.e);
svg.remove();
}
if (d3_mouse_bug44083) {
if (d3.event.touches && d3.event.touches.length > 0) {
point.x = d3.event.touches[0].pageX;
point.y = d3.event.touches[0].pageY;
} else if (d3_mouse_bug44083) {
point.x = d3.event.pageX;
point.y = d3.event.pageY;
} else {

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

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

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

@ -10,7 +10,10 @@ d3.svg.mouse = function(container) {
d3_mouse_bug44083 = !(ctm.f || ctm.e);
svg.remove();
}
if (d3_mouse_bug44083) {
if (d3.event.touches && d3.event.touches.length > 0) {
point.x = d3.event.touches[0].pageX;
point.y = d3.event.touches[0].pageY;
} else if (d3_mouse_bug44083) {
point.x = d3.event.pageX;
point.y = d3.event.pageY;
} else {