hasOwnProperty(o)&&(r=o,i[s]&&(r=i[s]+r.substring(0,1).toUpperCase()+r.substring(1)),t.style[r]=n[o]);n.userSelect=="none"&&(t.onselectstart=function(){return!1})}},n.detection={gestures:[],current:null,previous:null,stopped:!1,startDetect:function(t,r){if(this.current)return;this.stopped=!1,this.current={inst:t,startEvent:n.utils.extend({},r),lastEvent:!1,name:""},this.detect(r)},detect:function(t){if(!this.current||this.stopped)return;t=this.extendEventData(t);var r=this.current.inst.options;for(var i=0,s=this.gestures.length;i<s;i++){var o=this.gestures[i];if(!this.stopped&&r[o.name]!==!1&&o.handler.call(o,t,this.current.inst)===!1){this.stopDetect();break}}return this.current&&(this.current.lastEvent=t),t.eventType==n.EVENT_END&&!t.touches.length-1&&this.stopDetect(),t},stopDetect:function(){this.previous=n.utils.extend({},this.current),this.current=null,this.stopped=!0},extendEventData:function(t){var r=this.current.startEvent;if(r&&(t.touches.length!=r.touches.length||t.touches===r.touches)){r.touches=[];for(var i=0,s=t.touches.length;i<s;i++)r.touches.push(n.utils.extend({},t.touches[i]))}var o=t.timeStamp-r.timeStamp,u=t.center.pageX-r.center.pageX,a=t.center.pageY-r.center.pageY,f=n.utils.getVelocity(o,u,a);return n.utils.extend(t,{deltaTime:o,deltaX:u,deltaY:a,velocityX:f.x,velocityY:f.y,distance:n.utils.getDistance(r.center,t.center),angle:n.utils.getAngle(r.center,t.center),direction:n.utils.getDirection(r.center,t.center),scale:n.utils.getScale(r.touches,t.touches),rotation:n.utils.getRotation(r.touches,t.touches),startEvent:r}),t},register:function(r){var i=r.defaults||{};return i[r.name]===t&&(i[r.name]=!0),n.utils.extend(n.defaults,i,!0),r.index=r.index||1e3,this.gestures.push(r),this.gestures.sort(function(e,t){return e.index<t.index?-1:e.index>t.index?1:0}),this.gestures}},n.gestures=n.gestures||{},n.gestures.Hold={name:"hold",index:10,defaults:{hold_timeout:500,hold_threshold:1},timer:null,handler:function(t,r){switch(t.eventType){case n.EVENT_START:clearTimeout(this.timer),n.detection.current.name=this.name,this.timer=setTimeout(function(){n.detection.current.name=="hold"&&r.trigger("hold",t)},r.options.hold_timeout);break;case n.EVENT_MOVE:t.distance>r.options.hold_threshold&&clearTimeout(this.timer);break;case n.EVENT_END:clearTimeout(this.timer)}}},n.gestures.Tap={name:"tap",index:100,defaults:{tap_max_touchtime:250,tap_max_distance:10,tap_always:!0,doubletap_distance:20,doubletap_interval:300},handler:function(t,r){if(t.eventType==n.EVENT_END){var i=n.detection.previous,s=!1;if(t.deltaTime>r.options.tap_max_touchtime||t.distance>r.options.tap_max_distance)return;i&&i.name=="tap"&&t.timeStamp-i.lastEvent.timeStamp<r.options.doubletap_interval&&t.distance<r.options.doubletap_distance&&(r.trigger("doubletap",t),s=!0);if(!s||r.options.tap_always)n.detection.current.name="tap",r.trigger(n.detection.current.name,t)}}},n.gestures.Swipe={name:"swipe",index:40,defaults:{swipe_max_touches:1,swipe_velocity:.7},handler:function(t,r){if(t.eventType==n.EVENT_END){if(r.options.swipe_max_touches>0&&t.touches.length>r.options.swipe_max_touches)return;if(t.velocityX>r.options.swipe_velocity||t.velocityY>r.options.swipe_velocity)r.trigger(this.name,t),r.trigger(this.name+t.direction,t)}}},n.gestures.Drag={name:"drag",index:50,defaults:{drag_min_distance:10,drag_max_touches:1,drag_block_horizontal:!1,drag_block_vertical:!1,drag_lock_to_axis:!1,drag_lock_min_distance:25},triggered:!1,handler:function(t,r){if(n.detection.current.name!=this.name&&this.triggered){r.trigger(this.name+"end",t),this.triggered=!1;return}if(r.options.drag_max_touches>0&&t.touches.length>r.options.drag_max_touches)return;switch(t.eventType){case n.EVENT_START:this.triggered=!1;break;case n.EVENT_MOVE:if(t.distance<r.options.drag_min_distance&&n.detection.current.name!=this.name)return;n.detection.current.name=this.name;if(n.detection.current.lastEvent.drag_locked_to_axis||r.options.drag_lock_to_axis&&r.options.drag_lock_min_distance<=t.distance)t.drag_locked_to_axis=!0;var i=n.detection.current.lastEvent.direction;t.drag_locked_to_axis&&i!==t.direction&&(n.utils.isVertical(i)?t.direction=t.deltaY<0?n.DIRECTION_UP:n.DIRECTION_DOWN:t.direction=t.deltaX<0?n.DIRECTION_LEFT:n.DIRECTION_RIGHT),this.triggered||(r.trigger(this.name+"start",t),this.triggered=!0),r.trigger(this.name,t),r.trigger(this.name+t.direction,t),(r.options.drag_block_vertical&&n.utils.isVertical(t.direction)||r.options.drag_block_horizontal&&!n.utils.isVertical(t.direction))&&t.preventDefault();break;case n.EVENT_END:this.triggered&&r.trigger(this.name+"end",t),this.triggered=!1}}},n.gestures.Transform={name:"transform",index:45,defaults:{transform_min_scale:.01,transform_min_rotation:1,transform_always_block:!1},triggered:!1,handler:function(t,r){if(n.detection.current.name!=this.name&&this.triggered){r.trigger(this.name+"end",t),this.triggered=!1;return}if(t.touches.length<2)return;r.options.transform_always_block&&t.preventDefault();switch(t.eventType){case n.EVENT_START:this.triggered=!1;break;case n.EVENT_MOVE:var i=Math.abs(1-t.scale),s=Math.abs(t.rotation);if(i<r.options.transform_min_scale&&s<r.options.transform_min_rotation)return;n.detection.current.name=this.name,this.triggered||(r.trigger(this.name+"start",t),this.triggered=!0),r.trigger(this.name,t),s>r.options.transform_min_rotation&&r.trigger("rotate",t),i>r.options.transform_min_scale&&(r.trigger("pinch",t),r.trigger("pinch"+(t.scale<1?"in":"out"),t));break;case n.EVENT_END:this.triggered&&r.trigger(this.name+"end",t),this.triggered=!1}}},n.gestures.Touch={name:"touch",index:-Infinity,defaults:{prevent_default:!1,prevent_mouseevents:!1},handler:function(t,r){if(r.options.prevent_mouseevents&&t.pointerType==n.POINTER_MOUSE){t.stopDetect();return}r.options.prevent_default&&t.preventDefault(),t.eventType==n.EVENT_START&&r.trigger(this.name,t)}},n.gestures.Release={name:"release",index:Infinity,handler:function(t,r){t.eventType==n.EVENT_END&&r.trigger(this.name,t)}},typeof module=="object"&&typeof module.exports=="object"?module.exports=n:(e.Hammer=n,typeof e.define=="function"&&e.define.amd&&e.define("hammer",[],function(){return n}))})(window),function(e,t){if(e===t)return;Hammer.

Prev | Next
Pg.: 1 ... 9 10 11 12 13 14 15 16 17 18 19 ... 66


Back to home | File page

Subscribe | Register | Login | N