Permalink
Browse files

gc

git-svn-id: https://modestmaps.googlecode.com/svn/trunk/js@916 a23cadb0-8de1-11de-82e5-a1837a67dc72
  • Loading branch information...
1 parent 624dbb6 commit 91b63d7bd1c93c24cb1d4cbcb95b1f1224d7ad21 migurski committed Jun 14, 2010
Showing with 1 addition and 208 deletions.
  1. +1 −208 examples/touch/index.html
View
@@ -12,6 +12,7 @@
function stderr(msg)
{
+ return;
req = new XMLHttpRequest();
req.open('POST', 'trace.php', false);
req.send(msg);
@@ -144,56 +145,11 @@
MM.addEvent(map.parent, 'gesturestart', this.getGestureStart());
*/
- MM.addEvent(map.parent, 'touchstart', this.getTouchStartLog());
- MM.addEvent(map.parent, 'touchmove', this.getTouchMoveLog());
- MM.addEvent(map.parent, 'touchend', this.getTouchEndLog());
-
MM.addEvent(map.parent, 'touchstart', this.getTouchStartMachine());
MM.addEvent(map.parent, 'touchmove', this.getTouchMoveMachine());
MM.addEvent(map.parent, 'touchend', this.getTouchEndMachine());
},
- getTouchStartLogHandler: null,
-
- getTouchStartLog: function() {
- if (!this.getTouchStartLogHandler) {
- var theHandler = this;
- this.getTouchStartLogHandler = function(e)
- {
- points = _.map(e.changedTouches, function(t) { return '(#' + t.identifier + ': ' + t.screenX + ', ' + t.screenY + ')'; }).join(', ');
- stderr(' touch start: ' + e.changedTouches.length + '/' + e.touches.length + ', ' + points);
- }
- }
- return this.getTouchStartLogHandler;
- },
-
- getTouchStartLogHandler: null,
-
- getTouchMoveLog: function() {
- if (!this.getTouchMoveLogHandler) {
- var theHandler = this;
- this.getTouchMoveLogHandler = function(e)
- {
- //stderr('touch move');
- }
- }
- return this.getTouchMoveLogHandler;
- },
-
- getTouchEndLogHandler: null,
-
- getTouchEndLog: function() {
- if (!this.getTouchEndLogHandler) {
- var theHandler = this;
- this.getTouchEndLogHandler = function(e)
- {
- points = _.map(e.changedTouches, function(t) { return '(#' + t.identifier + ': ' + t.screenX + ', ' + t.screenY + ')'; }).join(', ');
- stderr(' touch end: ' + e.changedTouches.length + '/' + e.touches.length + ', ' + points);
- }
- }
- return this.getTouchEndLogHandler;
- },
-
getTouchStartMachineHandler: null,
getTouchStartMachine: function() {
@@ -407,170 +363,7 @@
this.map.panBy(m[4], m[5]);
this.map.parent.style.webkitTransform = '';
}
-
-
-
- /*
- gestureStart: null,
- gestureChange: null,
- gestureCenter: null,
- gestureEnd: null,
-
- startCenter: null,
- startScale: undefined,
- startZoom: undefined,
-
- getGestureStart: function() {
- if (!this.gestureStart) {
- var theHandler = this;
- this.gestureStart = function(e) {
- MM.addEvent(theHandler.map.parent, 'touchmove', theHandler.getGestureCenter());
- MM.addEvent(theHandler.map.parent, 'gesturechange', theHandler.getGestureChange());
- MM.addEvent(theHandler.map.parent, 'gestureend', theHandler.getGestureEnd());
- theHandler.startScale = e.scale;
- theHandler.startZoom = theHandler.map.getZoom();
- return MM.cancelEvent(e);
- }
- }
- return this.gestureStart;
- },
-
- getGestureCenter: function() {
- if (!this.gestureCenter) {
- var theHandler = this;
- this.gestureCenter = function(e) {
- if (e.touches.length == 2) {
- var centerX = (e.touches[0].pageX + e.touches[1].pageX) / 2.0;
- var centerY = (e.touches[0].pageY + e.touches[1].pageY) / 2.0;
- theHandler.startCenter = new MM.Point(centerX, centerY);
- }
- }
- }
- return this.gestureCenter;
- },
- getGestureChange: function() {
- if (!this.gestureChange) {
- var theHandler = this;
- this.gestureChange = function(e) {
- if (theHandler.startScale !== undefined && theHandler.startZoom !== undefined) {
- var scaleFactor = e.scale / theHandler.startScale;
- var zoomFactor = Math.log(scaleFactor) / Math.log(2);
- zoomFactor = Math.round(zoomFactor);
- if (zoomFactor != 0 && theHandler.startCenter) {
- var currentZoom = theHandler.map.getZoom();
- var targetZoom = theHandler.startZoom + zoomFactor;
- theHandler.map.zoomByAbout(targetZoom - currentZoom, theHandler.startCenter);
- }
- }
- return MM.cancelEvent(e);
- }
- }
- return this.gestureChange;
- },
-
- getGestureEnd: function() {
- if (!this.gestureEnd) {
- var theHandler = this;
- this.gestureEnd = function(e) {
- MM.removeEvent(theHandler.map.parent, 'gesturechange', theHandler.getGestureChange());
- MM.removeEvent(theHandler.map.parent, 'touchmove', theHandler.getGestureCenter());
- MM.removeEvent(theHandler.map.parent, 'gestureend', theHandler.getGestureEnd());
- theHandler.startCenter = null;
- theHandler.startScale = undefined;
- theHandler.startZoom = undefined;
- return MM.cancelEvent(e);
- }
- }
- return this.gestureEnd;
- },
-
- touchStartHandler: null,
-
- getTouchStart: function() {
- if (!this.touchStartHandler) {
- var theHandler = this;
- this.touchStartHandler = function(e) {
- if (e.touches.length == 1) {
- MM.addEvent(document, 'touchcancel', theHandler.getTouchEnd());
- MM.addEvent(document, 'touchend', theHandler.getTouchEnd());
- MM.addEvent(document, 'touchmove', theHandler.getTouchMove());
- theHandler.prevTouch = new MM.Point(e.changedTouches[0].pageX, e.changedTouches[0].pageY);
- }
- return MM.cancelEvent(e);
- };
- }
- return this.touchStartHandler;
- },
-
- touchMoveHandler: null,
-
- getTouchMove: function() {
- if (!this.touchMoveHandler) {
- var theHandler = this;
- this.touchMoveHandler = function(e) {
- if (theHandler.prevTouch && e.touches.length == 1) {
- theHandler.map.panBy(e.touches[0].pageX - theHandler.prevTouch.x,
- e.touches[0].pageY - theHandler.prevTouch.y);
- theHandler.prevTouch.x = e.touches[0].pageX;
- theHandler.prevTouch.y = e.touches[0].pageY;
- }
- return MM.cancelEvent(e);
- };
- }
- return this.touchMoveHandler;
- },
-
- touchEndHandler: null,
-
- getTouchEnd: function() {
- if (!this.touchEndHandler) {
- var theHandler = this;
- this.touchEndHandler = function(e) {
- if (theHandler.prevTouch && e.touches.length == 0) {
- MM.removeEvent(document, 'touchend', theHandler.getTouchEnd());
- MM.removeEvent(document, 'touchcancel', theHandler.getTouchEnd());
- MM.removeEvent(document, 'touchmove', theHandler.getTouchMove());
- theHandler.prevTouch = null;
- }
- return MM.cancelEvent(e);
- };
- }
- return this.touchEndHandler;
- },
-
- doubleTapHandler: null,
-
- getDoubleTap: function() {
- if (!this.doubleTapHandler) {
- var theHandler = this,
- prevPoint = null,
- prevTime = 0;
- function distsq(p1,p2) {
- var dx = p2.x-p1.x,
- dy = p2.y-p1.y;
- return dx*dx + dy*dy;
- }
- this.doubleTapHandler = function(e) {
- if (e.touches.length == 1) {
- var point = new MM.Point(e.touches[0].pageX, e.touches[0].pageY);
- if (prevPoint) {
- var dist = distsq(prevPoint, point),
- dt = new Date().getTime() - prevTime;
- // TODO: find out what the "best" values for double tap tolerance are...
- if (dist < 100.0 && dt < 400) {
- theHandler.map.zoomByAbout(1, point);
- }
- }
- prevPoint = point;
- prevTime = new Date().getTime();
- }
- };
- }
- return this.doubleTapHandler;
- }
- */
-
};
})(com.modestmaps);

0 comments on commit 91b63d7

Please sign in to comment.