source: Dev/branches/jQueryUI/client/d3/examples/touch/touch.html @ 254

Last change on this file since 254 was 249, checked in by hendrikvanantwerpen, 13 years ago

This one's for Subversion, because it's so close...

First widget (stripped down sequencer).
Seperated client and server code in two direcotry trees.

File size: 1.3 KB
Line 
1<!DOCTYPE html>
2<html>
3  <head>
4    <meta name="viewport" content="initial-scale=1,maximum-scale=1"/>
5    <script type="text/javascript" src="../../d3.js"></script>
6    <style type="text/css">
7
8html, body {
9  height: 100%;
10}
11
12body {
13  margin: 0;
14}
15
16svg {
17  display: block;
18  overflow: hidden;
19  width: 100%;
20  height: 100%;
21}
22
23    </style>
24  </head>
25  <body>
26    <script type="text/javascript">
27
28var color = d3.scale.category10();
29
30var svg = d3.select("body").append("svg:svg");
31
32d3.select("body")
33    .on("touchstart", touch)
34    .on("touchmove", touch)
35    .on("touchend", touch);
36
37function touch() {
38  d3.event.preventDefault();
39
40  var circle = svg.selectAll("circle.touch")
41      .data(d3.svg.touches(svg.node()), function(d) { return d.identifier; })
42      .attr("cx", function(d) { return d[0]; })
43      .attr("cy", function(d) { return d[1]; });
44
45  circle.enter().append("svg:circle")
46      .attr("class", "touch")
47      .attr("cx", function(d) { return d[0]; })
48      .attr("cy", function(d) { return d[1]; })
49      .style("fill", function(d) { return color(d.identifier); })
50      .attr("r", 1e-6)
51    .transition()
52      .duration(500)
53      .ease("elastic")
54      .attr("r", 48);
55
56  circle.exit()
57      .attr("class", null)
58    .transition()
59      .attr("r", 1e-6)
60      .remove();
61}
62
63    </script>
64  </body>
65</html>
Note: See TracBrowser for help on using the repository browser.