event-flick-min.js revision 870b1351b8dad6efd508aacc807cd53dbd43b7c8
YUI.add("event-flick",function(E){var D="ontouchstart" in E.config.win,H={start:"touchstart",end:"touchend"},J={start:"mousedown",end:"mouseup"},I=(D)?H:J,L="start",M="end",B="ownerDocument",K="minVelocity",F="minDistance",A="_flickStart",C="_flickStartHandle",G="_flickEndHandle";E.Event.define("flick",{init:function(O,N,Q){var P=O.on(I[L],E.bind(this._onStart,this),null,O,N,Q);O.setData(C,P);},destroy:function(P,O,R){var Q=P.getData(C),N=P.getData(G);if(Q){Q.detach();P.setData(C,null);}if(N){N.detach();P.setData(G,null);}},processArgs:function(N){var O=(N[3])?N.splice(3,1):{};if(!(K in O)){O.minVelocity=this.MIN_VELOCITY;}if(!(F in O)){O.minDistance=this.MIN_DISTANCE;}return O;},_onStart:function(S,P,O,R){var T=true,N,Q;if(S.touches){T=(S.touches.length===1);S=S.touches[0];}if(T){S.preventDefault();P.setData(A,{time:new Date().getTime(),pageX:S.pageX,pageY:S.pageY,clientX:S.clientX,clientY:S.clientY});N=P.getData(G);if(!N){Q=P.get(B);N=Q.on(I[M],E.bind(this._onEnd,this),null,P,O,R);P.setData(G,N);}}},_onEnd:function(a,U,b,R){var Z=new Date().getTime(),N=U.getData(A),P=N,c=a,Q,T,W,Y,O,X,V,S;if(N){if(a.changedTouches){if(a.changedTouches.length===1&&a.touches.length===0){c=a.changedTouches[0];}else{N=false;}}if(N){Q=P.time;Z=new Date().getTime();T=Z-Q;W=b._extra;Y=[c.pageX-P.pageX,c.pageY-P.pageY];S=W.axis||(Math.abs(Y[0])>=Math.abs(Y[1]))?"x":"y";O=Y[(S==="x")?0:1];X=Math.abs(O);V=X/T;if(isFinite(V)&&V>=W.minVelocity&&X>=W.minDistance){R.fire({distance:O,time:T,velocity:V,axis:S,start:P,end:{time:Z,clientX:c.clientX,clientY:c.clientY,pageX:c.pageX,pageY:c.pageY}});}U.setData(A,null);}}},MIN_VELOCITY:0,MIN_DISTANCE:10});},"@VERSION@",{use:["node-base","event-touch","event-synthetic"]});