This repository has been archived by the owner on Dec 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmultiEvent.min.js
2 lines (2 loc) · 2.07 KB
/
multiEvent.min.js
1
2
/*! MultiEvent 0.7.0 | Copyright (c) 2013 Ryan Fitzer | License: (http://www.opensource.org/licenses/mit-license.php) */
!function(a,b){"function"==typeof define&&define.amd?define(b):a.multiEvent=b(a.detect)}(this,function(){function a(){d&&console.log(arguments)}function b(a){var b=[],c=window.navigator.msPointerEnabled,d=function(a){return a=a.isArray?a:[a],a.forEach(function(a){b.push(a)}),b};return a.pointer&&c?d(a.pointer):(a.touch&&f.hasTouch&&d(a.touch),a.mouse&&(!a.mouse.isArray&&f.hasEvent(a.mouse)?b.push(a.mouse):a.mouse.isArray?a.mouse.forEach(function(a){f.hasEvent(a)&&b.push(a)}):b.push(a.mouse)),b)}function c(a,c){return d=c,"object"==typeof a?(this.types=a,this.behavior="custom"):(this.types=e[a],this.behavior=a),this.events=b(this.types),this}var d=!1,e={on:{pointer:"MSPointerDown",touch:"touchstart",mouse:"click"},off:{pointer:"MSPointerUp",touch:"touchend",mouse:"mouseup"},over:{pointer:"MSPointerOver",mouse:"mouseover"},out:{pointer:"MSPointerOut",mouse:"mouseout"}},f={hasTouch:function(){return"Modernizr"in window?Modernizr.touch:"ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch},hasEvent:function(a){return"on"+a.toLowerCase()in document.documentElement}};return c.prototype={resolve:function(b){var c=this.types,d=b.type,e=b.originalEvent||b,f=e.pointerType,g=e.MSPOINTER_TYPE_TOUCH,h=e.MSPOINTER_TYPE_MOUSE,i=e.mozInputSource,j=e.MOZ_SOURCE_TOUCH,k=e.MOZ_SOURCE_MOUSE;switch(this.isMatch=!0,this.isTouch=!1,this.isMouse=!1,d){case c.pointer:a("switch case: pointer; event: ",c.pointer),f===g&&(this.isTouch=!0),f===h&&(this.isMouse=!0);break;case c.touch:a("switch case: types.touch"),this.isTouch=!0;break;case c.mouse:if(a("switch case: mouse; event: ",c.mouse),i){a("entered mozSrc"),i===j&&(this.isTouch=!0,this.isMatch=!1),i===k&&(this.isMouse=!0);break}if(("mouseover"===c.mouse||"mouseout"===c.mouse)&&"webkitMovementX"in e&&(a("entered webkitMovementX"),!e.webkitMovementX&&!e.webkitMovementY)){this.isTouch=!0,this.isMatch=!1;break}default:a("switch case: default; event: ",d),this.isMouse=!0}return this}},function(a){return new c(a)}});