event-gestures-min.js revision 69d872a16bd3a22915b9b3689723b262b87ec57e
YUI.add("event-flick",function(C){var G=("ontouchstart" in C.config.win&&!C.UA.chrome)?{start:"touchstart",end:"touchend"}:{start:"mousedown",end:"mouseup"},H="start",K="end",B="ownerDocument",I="minVelocity",E="minDistance",A="preventDefault",D="_fs",F="_fsh",L="_feh",J="nodeType";C.Event.define("flick",{on:function(N,M,P){var O=N.on(G[H],this._onStart,this,N,M,P);M[F]=O;},detach:function(O,N,Q){var P=N[F],M=N[L];if(P){P.detach();N[F]=null;}if(M){M.detach();N[L]=null;}},processArgs:function(M){var N=(M.length>3)?C.merge(M.splice(3,1)[0]):{};if(!(I in N)){N[I]=this.MIN_VELOCITY;}if(!(E in N)){N[E]=this.MIN_DISTANCE;}if(!(A in N)){N[A]=this.PREVENT_DEFAULT;}return N;},_onStart:function(Q,O,U,N){var M=true,T,S,R=U._extra.preventDefault,P=Q;if(Q.touches){M=(Q.touches.length===1);Q=Q.touches[0];}if(M){if(R){if(!R.call||R(Q)){P.preventDefault();}}Q.flick={time:new Date().getTime()};U[D]=Q;T=U[L];if(!T){S=(O.get(J)===9)?O:O.get(B);T=S.on(G[K],C.bind(this._onEnd,this),null,O,U,N);U[L]=T;}}},_onEnd:function(Z,T,a,Q){var X=new Date().getTime(),O=a[D],M=!!O,b=Z,P,S,Y,V,W,N,U,R;if(M){if(Z.changedTouches){if(Z.changedTouches.length===1&&Z.touches.length===0){b=Z.changedTouches[0];}else{M=false;}}if(M){V=a._extra;Y=V[A];if(Y){if(!Y.call||Y(Z)){b.preventDefault();}}P=O.flick.time;X=new Date().getTime();S=X-P;W=[b.pageX-O.pageX,b.pageY-O.pageY];R=V.axis||(Math.abs(W[0])>=Math.abs(W[1]))?"x":"y";N=W[(R==="x")?0:1];U=(S!==0)?N/S:0;if(isFinite(U)&&(Math.abs(N)>=V[E])&&(Math.abs(U)>=V[I])){Z.type="flick";Z.flick={time:S,distance:N,velocity:U,axis:R,start:O};Q.fire(Z);}a[D]=null;}}},MIN_VELOCITY:0,MIN_DISTANCE:0,PREVENT_DEFAULT:true});},"@VERSION@",{requires:["node-base","event-touch","event-synthetic"]});YUI.add("event-move",function(C){var G=("ontouchstart" in C.config.win&&!C.UA.chrome)?{start:"touchstart",move:"touchmove",end:"touchend"}:{start:"mousedown",move:"mousemove",end:"mouseup"},R="start",V="move",F="end",U="_msh",I="_mh",Q="_meh",L="_dmsh",J="_dmh",A="_dmeh",E="_ms",M="_m",T="minTime",N="minDistance",O="preventDefault",P="ownerDocument",K="nodeType",H=function(a,Y,Z){var W=(Z)?4:3,X=(Y.length>W)?C.merge(Y.splice(W,1)[0]):{};if(!(O in X)){X[O]=a.PREVENT_DEFAULT;}return X;},D=function(X,W){return W._extra.root||(X.get(K)===9)?X:X.get(P);},S=function(W,Y,X){W.pageX=Y.pageX;W.pageY=Y.pageY;W.screenX=Y.screenX;W.screenY=Y.screenY;W.clientX=Y.clientX;W.clientY=Y.clientY;W.target=Y.target||W.target;W.currentTarget=Y.currentTarget||W.currentTarget;W.button=(X&&X.button)||1;},B=C.Event.define;B("gesturemovestart",{on:function(X,W,Y){W[U]=X.on(G[R],this._onStart,this,X,W,Y);},delegate:function(Y,X,a,W){var Z=this;X[L]=Y.delegate(G[R],function(b){Z._onStart(b,Y,X,a,true);},W);},detachDelegate:function(Y,X,a,W){var Z=X[L];if(Z){Z.detach();X[L]=null;}},detach:function(X,W,Z){var Y=W[U];if(Y){Y.detach();W[U]=null;}},processArgs:function(W,X){var Y=H(this,W,X);if(!(T in Y)){Y[T]=this.MIN_TIME;}if(!(N in Y)){Y[N]=this.MIN_DISTANCE;}return Y;},_onStart:function(c,X,j,W,f){if(f){X=c.currentTarget;}var Y=j._extra,i=true,Z=Y.minTime,h=Y.minDistance,a=Y.button,b=Y.preventDefault,g=D(X,j),d;if(c.touches){if(c.touches){if(c.touches.length===1){S(c,c.touches[0],Y);}else{i=false;}}}else{i=(a===undefined)||(a===c.button);}if(i){if(b){if(!b.call||b(c)){c.preventDefault();}}if(Z===0||h===0){this._start(c,X,W,Y);}else{d=[c.pageX,c.pageY];if(Z>0){Y._ht=C.later(Z,this,this._start,[c,X,W,Y]);Y._hme=g.on(G[F],C.bind(function(){this._cancel(Y);},this));}if(h>0){Y._hm=g.on(G[V],C.bind(function(e){if(Math.abs(e.pageX-d[0])>h||Math.abs(e.pageY-d[1])>h){this._start(c,X,W,Y);}},this));}}}},_cancel:function(W){if(W._ht){W._ht.cancel();W._ht=null;}if(W._hme){W._hme.detach();W._hme=null;}if(W._hm){W._hm.detach();W._hm=null;}},_start:function(Y,W,X,Z){if(Z){this._cancel(Z);}Y.type="gesturemovestart";W.setData(E,Y);X.fire(Y);},MIN_TIME:0,MIN_DISTANCE:0,PREVENT_DEFAULT:false});B("gesturemove",{on:function(Y,X,a){var W=D(Y,X),Z=W.on(G[V],this._onMove,this,Y,X,a);X[I]=Z;},delegate:function(Y,X,a,W){var Z=this;X[J]=Y.delegate(G[V],function(b){Z._onMove(b,Y,X,a,true);},W);},detach:function(X,W,Z){var Y=W[I];if(Y){Y.detach();W[I]=null;}},detachDelegate:function(Y,X,a,W){var Z=X[J];if(Z){Z.detach();X[J]=null;}},processArgs:function(W,X){return H(this,W,X);},_onMove:function(c,a,Z,b,Y){if(Y){a=c.currentTarget;}var W=Z._extra.standAlone||a.getData(E),X=Z._extra.preventDefault;if(W){if(c.touches){if(c.touches.length===1){S(c,c.touches[0]);}else{W=false;}}if(W){if(X){if(!X.call||X(c)){c.preventDefault();}}c.type="gesturemove";b.fire(c);}}},PREVENT_DEFAULT:false});B("gesturemoveend",{on:function(Z,Y,a){var X=D(Z,Y),W=X.on(G[F],this._onEnd,this,Z,Y,a);Y[Q]=W;},delegate:function(Y,X,a,W){var Z=this;X[A]=Y.delegate(G[F],function(b){Z._onEnd(b,Y,X,a,true);},W);},detachDelegate:function(Y,X,a,W){var Z=X[A];if(Z){Z.detach();X[A]=null;}},detach:function(Y,X,Z){var W=X[Q];if(W){W.detach();X[Q]=null;}},processArgs:function(W,X){return H(this,W,X);},_onEnd:function(c,a,Y,b,X){if(X){a=c.currentTarget;}var Z=Y._extra.standAlone||a.getData(M)||a.getData(E),W=Y._extra.preventDefault;if(Z){if(c.changedTouches){if(c.changedTouches.length===1){S(c,c.changedTouches[0]);}else{Z=false;}}if(Z){if(W){if(!W.call||W(c)){c.preventDefault();}}c.type="gesturemoveend";b.fire(c);a.clearData(E);a.clearData(M);}}},PREVENT_DEFAULT:false});},"@VERSION@",{requires:["node-base","event-touch","event-synthetic"]});YUI.add("event-gestures",function(A){},"@VERSION@",{use:["event-flick","event-move"]});