Permalink
Browse files

Fix preventDefault for touch events.

  • Loading branch information...
1 parent 2035dac commit 4defaf65be9ab8dee6e201de43a34b5c53395428 @mbostock mbostock committed Apr 8, 2011
Showing with 23 additions and 33 deletions.
  1. +1 −1 examples/iphone4/iphone4.html
  2. +2 −7 polymaps.js
  3. +18 −18 polymaps.min.js
  4. +2 −7 src/Touch.js
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
+ <meta name="viewport" content="initial-scale=1,maximum-scale=1"/>
<script type="text/javascript" src="../../polymaps.js"></script>
<style type="text/css">
View
@@ -1847,7 +1847,6 @@ po.touch = function() {
locations = {}; // touch identifier -> location
window.addEventListener("touchmove", touchmove, false);
- window.addEventListener("touchend", touchend, false);
function touchstart(e) {
var i = -1,
@@ -1857,14 +1856,14 @@ po.touch = function() {
t = e.touches[i];
locations[t.identifier] = map.pointLocation(map.mouse(t));
}
- e.preventDefault();
}
function touchmove(e) {
switch (e.touches.length) {
case 1: {
var t0 = e.touches[0];
map.zoomBy(0, map.mouse(t0), locations[t0.identifier]);
+ e.preventDefault();
break;
}
case 2: { // TODO rotation!
@@ -1885,14 +1884,10 @@ po.touch = function() {
dc = Math.sqrt(cx * cx + cy * cy),
z2 = Math.log(dp / dc) / Math.log(2); // zoom level
map.zoomBy(z2 - map.zoom(), p2, l2);
+ e.preventDefault();
break;
}
}
- e.preventDefault();
- }
-
- function touchend(e) {
- e.preventDefault();
}
touch.map = function(x) {
Oops, something went wrong.

0 comments on commit 4defaf6

Please sign in to comment.