mbostock/d3 — Issue #569: D3 multi touch
Author: AnjaJugel
Created: 2012-02-24 13:59:15+00:00
State: open

Hi all,

I'm not sure, whether it's a bug, a feature or probably I simply used the d3 method incorrectly. My goal was to move two rectangles independently from each other by touching and moving each rect-UI-element at an iPad. However, with d3.svg.touches I was not able to allocate the respective touch event to each one of the rectangles.
Here is what I did and found out.

First, I appended two rectangles to an svg with ids rect1 and rect2, respectively:

var rect1 = chart.append("rect")
.attr("id", "rect1");
var rect2 = chart.append("rect")
.attr("id", "rect2");

Second, in the event handler on "touchmove" I asked for the touch events using
var touches = d3.svg.touches(rect1);
and
var touches = d3.svg.touches(rect2);
respectively.
However, all returned touch events were assigned to object rect2, independent from chosen container and where I touched the screen.

Therefore, I checked the implementation of d3.svg.touches() and found the function "d3.event.touches". This function returned the correct touch events with correct assignments to rect1 and rect2.

Thus, I used it in my code, but still am wondering, what I did wrong with d3.svg.touches.
Can somebody help me here?

Thanks a lot!
Anja