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