block by emeeks 840a3af6e48196de718a

Visualizing Touch Rotate

Full Screen

This is a simple example showing how you can calculate the necessary angle of rotation from a touch interaction utilizing d3.touches. The slope of the initial position of the line created from the first two touch fingertips is stored and compared to the slope of the current position of the line from those two inputs.

Notice that you need to use three fingers to signal that you’re “rotating” (instead of, say, zooming or panning) even though the actual rotation calculation ignores the third fingertip.

index.html