event-gestures-min.js revision 08b9f4876219d98e17ab55b60fa2966d1db95d0b
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],this._onStart,this,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);}},publishConfig:{emitFacade:false},processArgs:function(L){var M=(L[3])?L.splice(3,1)[0]:{};if(!(H in M)){M.minVelocity=this.MIN_VELOCITY;}if(!(D in M)){M.minDistance=this.MIN_DISTANCE;}return M;},fireFilter:function(M,L){var N=L[0],O=M._extra;return Math.abs(N.distance)>=O.minDistance&&N.velocity>=O.minVelocity;},_onStart:function(R,N,M,Q){var S=true,L,P,O=R;if(R.touches){S=(R.touches.length===1);R=R.touches[0];}if(S){O.preventDefault();R.flick={time:new Date().getTime()};N.setData(C,R);L=N.getData(K);if(!L){P=(N.get(I)===9)?N:N.get(A);L=P.on(F[J],B.bind(this._onEnd,this),null,N,M,Q);N.setData(K,L);}}},_onEnd:function(Y,S,Z,P){var X=new Date().getTime(),N=S.getData(C),L=!!N,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){a.preventDefault();O=N.flick.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)){Y.type="flick";Y.flick={time:R,distance:M,direction:M/V,velocity:T,axis:Q,start:N};P.fire(Y);}S.clearData(C);}}},MIN_VELOCITY:0,MIN_DISTANCE:10});},"@VERSION@",{requires:["node-base","event-touch","event-synthetic"]});YUI.add("event-move",function(B){var F=("ontouchstart" in B.config.win)?{start:"touchstart",move:"touchmove",end:"touchend"}:{start:"mousedown",move:"mousemove",end:"mouseup"},N="start",R="move",E="end",Q="_msh",H="_mh",M="_meh",D="_ms",J="_m",P="minTime",K="minDistance",L="ownerDocument",I="nodeType",O={emitFacade:false},G=function(S){return S[3]?S.splice(3,1)[0]:{};},C=function(T,S){return S._extra.root||(T.get(I)===9)?T:T.get(L);},A=B.Event.define;A("gesturemovestart",{init:function(T,S,U){T.setData(Q,T.on(F[N],this._onStart,this,T,S,U));},destroy:function(T,S,V){var U=T.getData(Q);if(U){U.detach();T.clearData(Q);}},processArgs:function(S){var T=G(S);if(!(P in T)){T[P]=this.MIN_TIME;}if(!(K in T)){T[K]=this.MIN_DISTANCE;}return T;},publishConfig:O,_onStart:function(Y,U,d,T){Y.preventDefault();var Z=Y,V=d._extra,S=true,W=V.minTime,c=V.minDistance,X=V.button,b=C(U,d),a;if(Y.touches){S=(Y.touches.length===1);Y=Y.touches[0];Y.target=Y.target||Z.target;Y.currentTarget=Y.currentTarget||Z.currentTarget;}else{S=(X===undefined)||(X=Y.button);}if(S){if(W===0||c===0){this._start(Y,U,T,V);}else{a=[Y.pageX,Y.pageY];if(W>0){V._ht=B.later(W,this,this._start,[Y,U,T,V]);V._hme=b.on(F[E],B.bind(function(){this._cancel(V);},this));}if(c>0){V._hm=b.on(F[R],B.bind(function(e){if(Math.abs(e.pageX-a[0])>c||Math.abs(e.pageY-a[1])>c){this._start(Y,U,T,V);}},this));}}}},_cancel:function(S){if(S._ht){S._ht.cancel();S._ht=null;}if(S._hme){S._hme.detach();S._hme=null;}if(S._hm){S._hm.detach();S._hm=null;}},_start:function(U,S,T,V){if(V){this._cancel(V);}U.type="gesturemovestart";S.setData(D,U);T.fire(U);},MIN_TIME:0,MIN_DISTANCE:0});A("gesturemove",{init:function(U,T,W){var S=C(U,T),V=S.on(F[R],this._onMove,this,U,T,W);U.setData(H,V);},processArgs:G,destroy:function(T,S,V){var U=T.getData(H);if(U){U.detach();T.clearData(H);}},publishConfig:O,_onMove:function(X,U,T,W){var S=T._extra.standAlone||U.getData(D),V=X;if(S){if(X.touches){S=(X.touches.length===1);X=X.touches[0];X.target=X.target||V.target;X.currentTarget=X.currentTarget||V.currentTarget;}if(S){V.preventDefault();X.type="gesturemove";U.setData(J,X);W.fire(X);}}}});A("gesturemoveend",{init:function(V,U,W){var T=C(V,U),S=T.on(F[E],this._onEnd,this,V,U,W);V.setData(M,S);},processArgs:G,destroy:function(U,T,V){var S=U.getData(M);if(S){S.detach();U.clearData(M);}},publishConfig:O,_onEnd:function(X,T,S,W){var V=S._extra.standAlone||T.getData(J)||T.getData(D),U=X;if(V){if(X.changedTouches){if(X.changedTouches.length===1){X=X.changedTouches[0];X.target=X.target||U.target;X.currentTarget=X.currentTarget||U.currentTarget;}else{V=false;}}if(V){U.preventDefault();X.type="gesturemoveend";T.clearData(D);T.clearData(J);W.fire(X);}}}});},"@VERSION@",{requires:["node-base","event-touch","event-synthetic"]});YUI.add("event-gestures",function(A){},"@VERSION@",{use:["event-flick","event-move"]});