[llvm-commits] [LNT] r164293 - in /lnt/trunk/lnt/server/ui/static/flot: jquery.flot.touch.js jquery.flot.touch.min.js
Michael Gottesman
mgottesman at apple.com
Thu Sep 20 00:05:19 PDT 2012
Author: mgottesman
Date: Thu Sep 20 02:05:19 2012
New Revision: 164293
URL: http://llvm.org/viewvc/llvm-project?rev=164293&view=rev
Log:
[LNT] Added in small fix vis-a-vis double touch to zoom.
Modified:
lnt/trunk/lnt/server/ui/static/flot/jquery.flot.touch.js
lnt/trunk/lnt/server/ui/static/flot/jquery.flot.touch.min.js
Modified: lnt/trunk/lnt/server/ui/static/flot/jquery.flot.touch.js
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/static/flot/jquery.flot.touch.js?rev=164293&r1=164292&r2=164293&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/static/flot/jquery.flot.touch.js (original)
+++ lnt/trunk/lnt/server/ui/static/flot/jquery.flot.touch.js Thu Sep 20 02:05:19 2012
@@ -6,7 +6,9 @@
function init(plot) {
var isOneTouch = false;
var isTwoTouch = false;
+ var isPan = false;
var lastTouchCenter = [0,0];
+ var lastDoubleTouchCenter = [0,0];
var lastTouchPosition = [0,0];
var lastTwoTouchPosition = [[0,0],[0,0]];
var lastTwoTouchDistance = Infinity;
@@ -29,8 +31,8 @@
lastTouchPosition = [touches[0].pageX,
touches[0].pageY];
- lastTouchCenter = [touches[0].pageX - offset.left,
- touches[0].pageY - offset.top];
+ lastDoubleTouchCenter = [touches[0].pageX - offset.left,
+ touches[0].pageY - offset.top];
} else if (touches.length === 2) {
// Prepare for pinch zoom.
isTwoTouch = true;
@@ -62,6 +64,7 @@
});
lastTouchPosition = newTouchPosition;
+ isPan = true;
} else if (isTwoTouch && touches.length === 2) {
// If we hit a touchmove with one touch,
// we are zooming.
@@ -85,36 +88,28 @@
var touches = e.originalEvent.touches;
// Do the pan and or double click if it was quick.
- if (isOneTouch) {
+ if (isOneTouch && !isPan) {
+ console.log('At touch end. Trying to double click.');
var now = new Date().getTime();
var lasttime = lastTouchTime || now + 1; // now + 1 so the first time we are negative.
var delta = now - lasttime;
+ console.log("Now: " + now.toString() + "; LastTime: " + lasttime.toString() + " Delta: " + delta.toString());
+
if (delta < 500 && delta > 0) {
+ console.log('Double touch success.');
// We have a double touch.
- plot.zoom({ center: { left: lastTouchCenter[0],
- top: lastTouchCenter[1] }});
- }
-
- lastTouchTime = lastTouchTime !== null? null : now;
- } else if (isTwoTouch) {
- // Finish off our zoom.
-
- // We look at the delta from our last positions and zoom
- // in by the percent difference from the total distance in between
- // the previous distance in between the fingers total.
- var xdelta = touches[1].pageX - touches[0].pageX;
- var ydelta = touches[1].pageY - touches[0].pageY;
- var newTwoTouchDistance = Math.sqrt(xdelta*xdelta + ydelta*ydelta);
- var scale = (newTwoTouchDistance - lastTwoTouchDistance)/lastTwoTouchDistance;
- lastTwoTouchDistance = newTwoTouchDistance;
-
- plot.zoom({ amount: scale,
- center: { left: lastTouchCenter[0], top: lastTouchCenter[1] }});
+ plot.zoom({ center: { left: lastDoubleTouchCenter[0],
+ top: lastDoubleTouchCenter[1] }});
+ lastTouchTime = null;
+ } else {
+ lastTouchTime = now;
+ }
}
isOneTouch = false;
isTwoTouch = false;
+ isPan = false;
return false;
});
}
Modified: lnt/trunk/lnt/server/ui/static/flot/jquery.flot.touch.min.js
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/static/flot/jquery.flot.touch.min.js?rev=164293&r1=164292&r2=164293&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/static/flot/jquery.flot.touch.min.js (original)
+++ lnt/trunk/lnt/server/ui/static/flot/jquery.flot.touch.min.js Thu Sep 20 02:05:19 2012
@@ -1,3 +1,4 @@
-(function(j){j.plot.plugins.push({init:function(d){var g=!1,h=!1,e=[0,0],i=[0,0],f=Infinity,k=null;d.hooks.bindEvents.push(function(c){if(!1!==c.getOptions().touch.enabled){var d=c.getPlaceholder();d.bind("touchstart",function(a){var a=a.originalEvent.touches,b=c.offset();1===a.length?(g=!0,i=[a[0].pageX,a[0].pageY],e=[a[0].pageX-b.left,a[0].pageY-b.top]):2===a.length&&(h=!0,e=[(a[1].pageX+a[0].pageX)/2-b.left,(a[1].pageY+a[0].pageY)/2-b.top],b=a[1].pageX-a[0].pageX,a=a[1].pageY-a[0].pageY,f=Math.sqrt(b*
-b+a*a));return!1});d.bind("touchmove",function(a){var b=a.originalEvent.touches;g&&1===b.length?(a=[b[0].pageX,b[0].pageY],c.pan({left:i[0]-a[0],top:i[1]-a[1]}),i=a):h&&2===b.length&&(a=b[1].pageX-b[0].pageX,b=b[1].pageY-b[0].pageY,a=Math.sqrt(a*a+b*b),c.zoom({amount:1+(a-f)/f,center:{left:e[0],top:e[1]}}),f=a);return!1});d.bind("touchend",function(a){var b=a.originalEvent.touches;g?(a=(new Date).getTime(),b=a-(k||a+1),500>b&&0<b&&c.zoom({center:{left:e[0],top:e[1]}}),k=null!==k?null:a):h&&(a=b[1].pageX-
-b[0].pageX,b=b[1].pageY-b[0].pageY,a=Math.sqrt(a*a+b*b),b=(a-f)/f,f=a,c.zoom({amount:b,center:{left:e[0],top:e[1]}}));return h=g=!1})}});d.hooks.shutdown.push(function(c){!1!==c.getOptions().touch.enabled&&c.getPlaceholder().unbind("touchstart").unbind("touchmove").unbind("touchend")});j(document).bind("ready orientationchange",function(){window.scrollTo(0,1);setTimeout(function(){j.plot(placeholder,d.getData(),d.getOptions())},50)})},options:{touch:{enabled:!0}},name:"touch",version:"1.0"})})(jQuery);
+(function(h){h.plot.plugins.push({init:function(c){var e=!1,i=!1,j=!1,k=[0,0],l=[0,0],f=[0,0],g=Infinity,m=null;c.hooks.bindEvents.push(function(d){if(!1!==d.getOptions().touch.enabled){var c=d.getPlaceholder();c.bind("touchstart",function(a){var a=a.originalEvent.touches,b=d.offset();1===a.length?(e=!0,f=[a[0].pageX,a[0].pageY],l=[a[0].pageX-b.left,a[0].pageY-b.top]):2===a.length&&(i=!0,k=[(a[1].pageX+a[0].pageX)/2-b.left,(a[1].pageY+a[0].pageY)/2-b.top],b=a[1].pageX-a[0].pageX,a=a[1].pageY-a[0].pageY,
+g=Math.sqrt(b*b+a*a));return!1});c.bind("touchmove",function(a){var b=a.originalEvent.touches;e&&1===b.length?(a=[b[0].pageX,b[0].pageY],d.pan({left:f[0]-a[0],top:f[1]-a[1]}),f=a,j=!0):i&&2===b.length&&(a=b[1].pageX-b[0].pageX,b=b[1].pageY-b[0].pageY,a=Math.sqrt(a*a+b*b),d.zoom({amount:1+(a-g)/g,center:{left:k[0],top:k[1]}}),g=a);return!1});c.bind("touchend",function(){if(e&&!j){console.log("At touch end. Trying to double click.");var a=(new Date).getTime(),b=m||a+1,c=a-b;console.log("Now: "+a.toString()+
+"; LastTime: "+b.toString()+" Delta: "+c.toString());500>c&&0<c?(console.log("Double touch success."),d.zoom({center:{left:l[0],top:l[1]}}),m=null):m=a}return j=i=e=!1})}});c.hooks.shutdown.push(function(c){!1!==c.getOptions().touch.enabled&&c.getPlaceholder().unbind("touchstart").unbind("touchmove").unbind("touchend")});h(document).bind("ready orientationchange",function(){window.scrollTo(0,1);setTimeout(function(){h.plot(placeholder,c.getData(),c.getOptions())},50)})},options:{touch:{enabled:!0}},
+name:"touch",version:"1.0"})})(jQuery);
More information about the llvm-commits
mailing list