text: /*
  	"Swipe" event proxy (1+ fingers).
  	----------------------------------------------------
  	CONFIGURE: snap, threshold, maxFingers.
  	----------------------------------------------------
  	Event.add(window, "swipe", function(event, self) {
  		console.log(self.velocity, self.angle);
  	});
  */
  
  if (typeof(Event) === "undefined") var Event = {};
  if (typeof(Event.proxy) === "undefined") Event.proxy = {};
  
  Event.proxy = (function(root) { "use strict";
  
  var RAD_DEG = Math.PI / 180;
  
  root.swipe = function(conf) {
  	conf.snap = conf.snap || 90; // angle snap.
  	conf.threshold = conf.threshold || 1; // velocity threshold.
  	// Tracking the events.
  	conf.onPointerDown = function (event) {
  		if (root.pointerStart(event, self, conf)) {
  			Event.add(conf.doc, "mousemove", conf.onPointerMove).listener(event);
  			Event.add(conf.doc, "mouseup", conf.onPointerUp);
  		}
  	};
  	conf.onPointerMove = function (event) {
  		var touches = event.changedTouches || root.getCoords(event);
  		var length = touches.length;
  		for (var i = 0; i < length; i ++) {
  			var touch = touches[i];
  			var sid = touch.identifier || Infinity;
  			var o = conf.tracker[sid];
  			// Identifier defined outside of listener.
  			if (!o) continue; 
  			o.move.x = touch.pageX;
  			o.move.y = touch.pageY;
  			o.moveTime = (new Date).getTime();
  		}
  	};
  	conf.onPointerUp = function(event) {
  		if (root.pointerEnd(event, self, conf)) {
  			Event.remove(conf.doc, "mousemove", conf.onPointerMove);
  			Event.remove(conf.doc, "mouseup", conf.onPointerUp);
  			///
  			var velocity1;
  			var velocity2
  			var degree1;
  			var degree2;
  		/// Calculate centroid of gesture.
  		var start = { x: 0, y: 0 };
  		var endx = 0;
  		var endy = 0;
  		var length = 0;
  			///
  			for (var sid in conf.tracker) {
  				var touch = conf.tracker[sid];
  				var xdist = touch.move.x - touch.start.x;
  				var ydist = touch.move.y - touch.start.y;
  
  			endx += touch.move.x;
  			endy += touch.move.y;
  			start.x += touch.start.x;
  			start.y += touch.start.y;
  			length ++;
  
  
  				var distance = Math.sqrt(xdist * xdist + ydist * ydist);
  				var ms = touch.moveTime - touch.startTime;
  				var degree2 = Math.atan2(xdist, ydist) / RAD_DEG + 180;
  				var velocity2 = ms ? distance / ms : 0;
  				if (typeof(degree1) === "undefined") {
  					degree1 = degree2;
  					velocity1 = velocity2;
  				} else if (Math.abs(degree2 - degree1) <= 20) {
  					degree1 = (degree1 + degree2) / 2;
  					velocity1 = (velocity1 + velocity2) / 2;
  				} else {
  					return;
  				}
  			}
  			///
  			if (velocity1 > conf.threshold) {
  				start.x /= length;
  				start.y /= length;
  				self.start = start;
  				self.x = endx / length;
  				self.y = endy / length;
  				self.angle = -((((degree1 / conf.snap + 0.5) >> 0) * conf.snap || 360) - 360);
  				self.velocity = velocity1;
  				self.fingers = conf.gestureFingers;
  				self.state = "swipe";
  				conf.listener(event, self);
  			}
  		}
  	};
  	// Generate maintenance commands, and other configurations.
  	var self = root.pointerSetup(conf);
  	// Attach events.
  	Event.add(conf.target, "mousedown", conf.onPointerDown);
  	// Return this object.
  	return self;
  };
  
  Event.Gesture = Event.Gesture || {};
  Event.Gesture._gestureHandlers = Event.Gesture._gestureHandlers || {};
  Event.Gesture._gestureHandlers.swipe = root.swipe;
  
  return root;
  
  })(Event.proxy);