@livelybone/mouse-events
Advanced tools
Comparing version 1.0.0-beta to 1.0.0
import * as MouseWheel from '@livelybone/mouse-wheel' | ||
declare namespace Utils { | ||
export interface CustomListener<T = Event> { | ||
(ev: T): any | ||
} | ||
declare const $isMobile: boolean | ||
export interface RemoveListener { | ||
(): void | ||
} | ||
interface CustomListener<T = Event> { | ||
(ev: T): any | ||
} | ||
export function $addListener<T = Event>( | ||
element: Element | Window, | ||
eventName: string, | ||
listener: CustomListener<T>, | ||
useCapture?: boolean, | ||
): RemoveListener | ||
interface RemoveListener { | ||
(): void | ||
} | ||
export const $isMobile: boolean | ||
declare function $addListener<T extends Event = Event>( | ||
element: Element | Window, | ||
eventName: string, | ||
listener: CustomListener<T>, | ||
useCapture?: boolean, | ||
): RemoveListener | ||
declare const Utils$isMobile: typeof $isMobile | ||
type UtilsCustomListener = CustomListener | ||
type UtilsRemoveListener = RemoveListener | ||
declare const Utils$addListener: typeof $addListener | ||
declare namespace Utils { | ||
export { | ||
Utils$isMobile as $isMobile, | ||
UtilsCustomListener as CustomListener, | ||
UtilsRemoveListener as RemoveListener, | ||
Utils$addListener as $addListener, | ||
} | ||
} | ||
@@ -36,16 +47,27 @@ | ||
declare function bind( | ||
element: Element | Window, | ||
listener: DragMoveListener, | ||
useCapture?: boolean, | ||
): RemoveListener | ||
declare function bind( | ||
listener: DragMoveListener, | ||
useCapture?: boolean, | ||
): RemoveListener | ||
declare const DragMoveOriginalEvent: typeof OriginalEvent | ||
declare const DragMoveDragMoveEventType: typeof DragMoveEventType | ||
type DragMoveDragMoveEvent = DragMoveEvent | ||
type DragMoveDragMoveListener = DragMoveListener | ||
declare const DragMovebind: typeof bind | ||
declare namespace DragMove { | ||
declare function bind( | ||
element: Element | Window, | ||
listener: DragMoveListener, | ||
useCapture?: boolean, | ||
): Utils.RemoveListener | ||
declare function bind( | ||
listener: DragMoveListener, | ||
useCapture?: boolean, | ||
): Utils.RemoveListener | ||
export { bind } | ||
export { | ||
DragMoveOriginalEvent as OriginalEvent, | ||
DragMoveDragMoveEventType as DragMoveEventType, | ||
DragMoveDragMoveEvent as DragMoveEvent, | ||
DragMoveDragMoveListener as DragMoveListener, | ||
DragMovebind as bind, | ||
} | ||
} | ||
export { DragMove, MouseWheel, Utils } |
/** | ||
* Bundle of @livelybone/mouse-events | ||
* Generated: 2019-07-31 | ||
* Version: 1.0.0-beta | ||
* Generated: 2020-05-16 | ||
* Version: 1.0.0 | ||
* License: MIT | ||
@@ -46,3 +46,3 @@ * Author: 2631541504@qq.com | ||
if (i % 2) { | ||
ownKeys(source, true).forEach(function (key) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
@@ -53,3 +53,3 @@ }); | ||
} else { | ||
ownKeys(source).forEach(function (key) { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
@@ -64,3 +64,3 @@ }); | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
@@ -73,2 +73,3 @@ | ||
function _iterableToArrayLimit(arr, i) { | ||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; | ||
var _arr = []; | ||
@@ -99,6 +100,24 @@ var _n = true; | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
var $isMobile = isMobile(); | ||
var prefix = ''; | ||
@@ -110,3 +129,3 @@ var $addEventListener = 'addEventListener'; | ||
// detect event model | ||
if (window.addEventListener) { | ||
if ('addEventListener' in window) { | ||
$addEventListener = 'addEventListener'; | ||
@@ -130,7 +149,6 @@ $removeEventListener = 'removeEventListener'; | ||
} | ||
var $isMobile = isMobile(); | ||
var Utils = /*#__PURE__*/Object.freeze({ | ||
$addListener: $addListener, | ||
$isMobile: $isMobile | ||
$isMobile: $isMobile, | ||
$addListener: $addListener | ||
}); | ||
@@ -216,7 +234,7 @@ | ||
} else if (ev.type === EventType.move) { | ||
event = _objectSpread2({}, getEvent(ev, startEvent), { | ||
event = _objectSpread2(_objectSpread2({}, getEvent(ev, startEvent)), {}, { | ||
type: 'dragMove' | ||
}); | ||
} else if (ev.type === EventType.end) { | ||
event = _objectSpread2({}, getEvent(ev, startEvent), { | ||
event = _objectSpread2(_objectSpread2({}, getEvent(ev, startEvent)), {}, { | ||
type: 'dragMoveEnd' | ||
@@ -223,0 +241,0 @@ }); |
/** | ||
* Bundle of @livelybone/mouse-events | ||
* Generated: 2019-07-31 | ||
* Version: 1.0.0-beta | ||
* Generated: 2020-05-16 | ||
* Version: 1.0.0 | ||
* License: MIT | ||
@@ -9,2 +9,2 @@ * Author: 2631541504@qq.com | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).DragMoveMouseEvents={})}(this,function(e){"use strict";function n(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),t.push.apply(t,o)}return t}function p(r){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?n(i,!0).forEach(function(e){var n,t,o;n=r,o=i[t=e],t in n?Object.defineProperty(n,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[t]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):n(i).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}function t(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=[],o=!0,r=!1,i=void 0;try{for(var a,d=e[Symbol.iterator]();!(o=(a=d.next()).done)&&(t.push(a.value),!n||t.length!==n);o=!0);}catch(e){r=!0,i=e}finally{try{o||null==d.return||d.return()}finally{if(r)throw i}}return t}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var o=a,r=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,i=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino|android|ipad|playbook|silk/i;function a(e){var n=(e=e||{}).ua;return n||"undefined"==typeof navigator||(n=navigator.userAgent),n&&n.headers&&"string"==typeof n.headers["user-agent"]&&(n=n.headers["user-agent"]),"string"==typeof n&&(e.tablet?i.test(n):r.test(n))}a.isMobile=o;var d="",c="addEventListener",l="removeEventListener";function u(e,n,t,o){var r=d+n;return e[c].bind(e)(r,t,o),function(){e[l].bind(e)(r,t,o)}}"undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener?(c="addEventListener",l="removeEventListener"):(c="attachEvent",l="detachEvent",d="on"));var s=o(),f=s?"mobile":"pc",b={start:{pc:"mousedown",mobile:"touchstart"}[f],move:{pc:"mousemove",mobile:"touchmove"}[f],end:{pc:"mouseup",mobile:"touchend"}[f]};function m(e){var n=null;if(s)if(0<e.changedTouches.length)n=t(e.changedTouches,1)[0];else if(0<e.targetTouched.length){n=t(e.changedTouches,1)[0]}else{n=t(e.touches,1)[0]}return n||e}function v(e,n){return{deltaX:m(e).clientX-m(n).clientX,deltaY:m(e).clientY-m(n).clientY,originalEvent:e}}e.bind=function(e,i,a){var d,c;return"function"==typeof e&&(a=i,i=e,e=window),u(e,b.start,function e(n){var t={deltaX:0,deltaY:0,originalEvent:n,type:"dragMoveStart"};if(n.type===b.start){d=n;var o=u(window,b.move,e,a),r=u(window,b.end,e,a);c=function(){o(),r()}}else n.type===b.move?t=p({},v(n,d),{type:"dragMove"}):n.type===b.end&&(t=p({},v(n,d),{type:"dragMoveEnd"}),c&&c());i(t)},a)},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).DragMoveMouseEvents={})}(this,function(e){"use strict";function t(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function d(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?t(Object(i),!0).forEach(function(e){var t,n,r;t=o,r=i[n=e],n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=e[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var o=l,i=l,a=l,c=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,u=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino|android|ipad|playbook|silk/i;function l(e){var t=(e=e||{}).ua;if(t||"undefined"==typeof navigator||(t=navigator.userAgent),t&&t.headers&&"string"==typeof t.headers["user-agent"]&&(t=t.headers["user-agent"]),"string"!=typeof t)return!1;var n=e.tablet?u.test(t):c.test(t);return!n&&e.tablet&&e.featureDetect&&navigator&&1<navigator.maxTouchPoints&&-1!==t.indexOf("Macintosh")&&-1!==t.indexOf("Safari")&&(n=!0),n}o.isMobile=i,o.default=a;var p=i(),f="",s="addEventListener",b="removeEventListener";function m(e,t,n,r){var o=f+t;return e[s].bind(e)(o,n,r),function(){e[b].bind(e)(o,n,r)}}"undefined"!=typeof window&&"undefined"!=typeof document&&("addEventListener"in window?(s="addEventListener",b="removeEventListener"):(s="attachEvent",b="detachEvent",f="on"));var v=p?"mobile":"pc",y={start:{pc:"mousedown",mobile:"touchstart"}[v],move:{pc:"mousemove",mobile:"touchmove"}[v],end:{pc:"mouseup",mobile:"touchend"}[v]};function g(e){var t=null;return p&&(t=0<e.changedTouches.length||0<e.targetTouched.length?n(e.changedTouches,1)[0]:n(e.touches,1)[0]),t||e}function h(e,t){return{deltaX:g(e).clientX-g(t).clientX,deltaY:g(e).clientY-g(t).clientY,originalEvent:e}}e.bind=function(e,i,a){var c,u;return"function"==typeof e&&(a=i,i=e,e=window),m(e,y.start,function e(t){var n,r,o={deltaX:0,deltaY:0,originalEvent:t,type:"dragMoveStart"};t.type===y.start?(c=t,n=m(window,y.move,e,a),r=m(window,y.end,e,a),u=function(){n(),r()}):t.type===y.move?o=d(d({},h(t,c)),{},{type:"dragMove"}):t.type===y.end&&(o=d(d({},h(t,c)),{},{type:"dragMoveEnd"}),u&&u()),i(o)},a)},Object.defineProperty(e,"__esModule",{value:!0})}); |
/** | ||
* Bundle of @livelybone/mouse-events | ||
* Generated: 2019-07-31 | ||
* Version: 1.0.0-beta | ||
* Generated: 2020-05-16 | ||
* Version: 1.0.0 | ||
* License: MIT | ||
@@ -9,2 +9,2 @@ * Author: 2631541504@qq.com | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).MouseEvents={})}(this,function(e){"use strict";function t(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,o)}return n}function u(r){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?t(i,!0).forEach(function(e){var t,n,o;t=r,o=i[n=e],n in t?Object.defineProperty(t,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[n]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):t(i).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],o=!0,r=!1,i=void 0;try{for(var a,d=e[Symbol.iterator]();!(o=(a=d.next()).done)&&(n.push(a.value),!t||n.length!==t);o=!0);}catch(e){r=!0,i=e}finally{try{o||null==d.return||d.return()}finally{if(r)throw i}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var o=a,r=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,i=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino|android|ipad|playbook|silk/i;function a(e){var t=(e=e||{}).ua;return t||"undefined"==typeof navigator||(t=navigator.userAgent),t&&t.headers&&"string"==typeof t.headers["user-agent"]&&(t=t.headers["user-agent"]),"string"==typeof t&&(e.tablet?i.test(t):r.test(t))}a.isMobile=o;var d="",l="addEventListener",c="removeEventListener";function p(e,t,n,o){var r=d+t;return e[l].bind(e)(r,n,o),function(){e[c].bind(e)(r,n,o)}}"undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener?(l="addEventListener",c="removeEventListener"):(l="attachEvent",c="detachEvent",d="on"));var s=o(),f=Object.freeze({$addListener:p,$isMobile:s}),v=s?"mobile":"pc",m={start:{pc:"mousedown",mobile:"touchstart"}[v],move:{pc:"mousemove",mobile:"touchmove"}[v],end:{pc:"mouseup",mobile:"touchend"}[v]};function b(e){var t=null;if(s)if(0<e.changedTouches.length)t=n(e.changedTouches,1)[0];else if(0<e.targetTouched.length){t=n(e.changedTouches,1)[0]}else{t=n(e.touches,1)[0]}return t||e}function w(e,t){return{deltaX:b(e).clientX-b(t).clientX,deltaY:b(e).clientY-b(t).clientY,originalEvent:e}}var h=Object.freeze({bind:function(e,i,a){var d,l;return"function"==typeof e&&(a=i,i=e,e=window),p(e,m.start,function e(t){var n={deltaX:0,deltaY:0,originalEvent:t,type:"dragMoveStart"};if(t.type===m.start){d=t;var o=p(window,m.move,e,a),r=p(window,m.end,e,a);l=function(){o(),r()}}else t.type===m.move?n=u({},w(t,d),{type:"dragMove"}):t.type===m.end&&(n=u({},w(t,d),{type:"dragMoveEnd"}),l&&l());i(n)},a)}}),y="",g="addEventListener",E="removeEventListener",O="wheel";function M(i,e,a,t){var d,n=3<arguments.length&&void 0!==t?t:{},l={debounceTime:n.debounceTime||0,interval:n.interval||500,useCapture:n.useCapture||!1},u=0;function o(e){var t="wheel"===O?e:function(e){var t=e||window.event,n={originalEvent:t,timeStamp:t.timeStamp,target:t.target||t.srcElement,type:"wheel",deltaMode:"MozMousePixelScroll"===t.type?0:1,deltaX:0,deltaY:0,deltaZ:0,preventDefault:function(){t.preventDefault?t.preventDefault():t.returnValue=!1}};return"mousewheel"===O?(n.deltaY=-.025*t.wheelDelta,t.wheelDeltaX&&(n.deltaX=-.025*t.wheelDeltaX)):n.deltaY=t.detail,n}(e),n=t.timeStamp-u,o="wheelMove";if(!(n<l.debounceTime)){l.interval<n&&(o="wheelStart");var r=1;1===t.deltaMode?r=function(e){var t=e instanceof Window?document.documentElement:e,n=window.getComputedStyle(t).fontSize||"16px";return parseInt(n)/2}(i):2===t.deltaMode&&(r=window.innerHeight),a({dx:t.deltaX*r||0,dy:t.deltaY*r||0,dz:t.deltaZ*r||0,originalEvent:t,type:o}),u=t.timeStamp,clearTimeout(d),d=setTimeout(function(){a({dx:0,dy:0,dz:0,originalEvent:{timeStamp:t.timeStamp+l.interval},type:"wheelEnd"})},l.interval)}}return(0,i[g])(y+e,o,l.useCapture),function(){(0,i[E])(y+e,o,l.useCapture)}}"undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener?(g="addEventListener",E="removeEventListener"):(g="attachEvent",E="detachEvent",y="on"),O="onwheel"in document.createElement("div")?"wheel":void 0!==window.onmousewheel?"mousewheel":"DOMMouseScroll");var x=Object.freeze({bind:function(e,t,n){return"function"==typeof e&&(n=t,t=e,e=window),M(e,"DOMMouseScroll"===O?"MozMousePixelScroll":O,t,n)}});e.DragMove=h,e.MouseWheel=x,e.Utils=f,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).MouseEvents={})}(this,function(e){"use strict";function t(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function u(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?t(Object(i),!0).forEach(function(e){var t,n,r;t=o,r=i[n=e],n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,l=e[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw i}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var o=c,i=c,a=c,l=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,d=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino|android|ipad|playbook|silk/i;function c(e){var t=(e=e||{}).ua;if(t||"undefined"==typeof navigator||(t=navigator.userAgent),t&&t.headers&&"string"==typeof t.headers["user-agent"]&&(t=t.headers["user-agent"]),"string"!=typeof t)return!1;var n=e.tablet?d.test(t):l.test(t);return!n&&e.tablet&&e.featureDetect&&navigator&&1<navigator.maxTouchPoints&&-1!==t.indexOf("Macintosh")&&-1!==t.indexOf("Safari")&&(n=!0),n}o.isMobile=i,o.default=a;var p=i(),s="",f="addEventListener",m="removeEventListener";function v(e,t,n,r){var o=s+t;return e[f].bind(e)(o,n,r),function(){e[m].bind(e)(o,n,r)}}"undefined"!=typeof window&&"undefined"!=typeof document&&("addEventListener"in window?(f="addEventListener",m="removeEventListener"):(f="attachEvent",m="detachEvent",s="on"));var b=Object.freeze({$isMobile:p,$addListener:v}),y=p?"mobile":"pc",h={start:{pc:"mousedown",mobile:"touchstart"}[y],move:{pc:"mousemove",mobile:"touchmove"}[y],end:{pc:"mouseup",mobile:"touchend"}[y]};function w(e){var t=null;return p&&(t=0<e.changedTouches.length||0<e.targetTouched.length?n(e.changedTouches,1)[0]:n(e.touches,1)[0]),t||e}function g(e,t){return{deltaX:w(e).clientX-w(t).clientX,deltaY:w(e).clientY-w(t).clientY,originalEvent:e}}var O=Object.freeze({bind:function(e,i,a){var l,d;return"function"==typeof e&&(a=i,i=e,e=window),v(e,h.start,function e(t){var n,r,o={deltaX:0,deltaY:0,originalEvent:t,type:"dragMoveStart"};t.type===h.start?(l=t,n=v(window,h.move,e,a),r=v(window,h.end,e,a),d=function(){n(),r()}):t.type===h.move?o=u(u({},g(t,l)),{},{type:"dragMove"}):t.type===h.end&&(o=u(u({},g(t,l)),{},{type:"dragMoveEnd"}),d&&d()),i(o)},a)}}),E="",S="addEventListener",M="removeEventListener",j="wheel";function x(p,e,s,t){var f,n=3<arguments.length&&void 0!==t?t:{},m={debounceTime:n.debounceTime||0,interval:n.interval||500,useCapture:n.useCapture||!1},v=0;function r(e){var t,n,r,o,i,a,l,d="wheel"===j?e:(t=e||window.event,n={originalEvent:t,timeStamp:t.timeStamp,target:t.target||t.srcElement,type:"wheel",deltaMode:"MozMousePixelScroll"===t.type?0:1,deltaX:0,deltaY:0,deltaZ:0,preventDefault:function(){t.preventDefault?t.preventDefault():t.returnValue=!1}},"mousewheel"===j?(n.deltaY=-.025*t.wheelDelta,t.wheelDeltaX&&(n.deltaX=-.025*t.wheelDeltaX)):n.deltaY=t.detail,n),u=d.timeStamp-v,c="wheelMove";u<m.debounceTime||(m.interval<u&&(c="wheelStart"),(r=1)===d.deltaMode?(i=(o=p)instanceof Window?document.documentElement:o,a=window.getComputedStyle(i).fontSize||"16px",r=parseInt(a,10)):2===d.deltaMode&&(r=window.innerHeight),l="wheelStart"!==c?u:0,s({dx:d.deltaX*r||0,dy:d.deltaY*r||0,dz:d.deltaZ*r||0,dTime:l,originalEvent:d,type:c}),v=d.timeStamp,clearTimeout(f),f=setTimeout(function(){s({dx:0,dy:0,dz:0,dTime:l+m.interval,originalEvent:{timeStamp:d.timeStamp+m.interval},type:"wheelEnd"})},m.interval))}return(0,p[S])(E+e,r,m.useCapture),function(){(0,p[M])(E+e,r,m.useCapture)}}"undefined"!=typeof window&&"undefined"!=typeof document&&("addEventListener"in window?(S="addEventListener",M="removeEventListener"):(S="attachEvent",M="detachEvent",E="on"),j="onwheel"in document.createElement("div")?"wheel":void 0!==window.onmousewheel?"mousewheel":"DOMMouseScroll");var D=Object.freeze({bind:function(e,t,n){return"function"==typeof e&&(n=t,t=e,e=window),x(e,"DOMMouseScroll"===j?"MozMousePixelScroll":j,t,n)}});e.DragMove=O,e.MouseWheel=D,e.Utils=b,Object.defineProperty(e,"__esModule",{value:!0})}); |
/** | ||
* Bundle of @livelybone/mouse-events | ||
* Generated: 2019-07-31 | ||
* Version: 1.0.0-beta | ||
* Generated: 2020-05-16 | ||
* Version: 1.0.0 | ||
* License: MIT | ||
@@ -9,2 +9,2 @@ * Author: 2631541504@qq.com | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).MouseWheelMouseEvents=t()}(this,function(){"use strict";var i="",m="addEventListener",c="removeEventListener",f="wheel";function o(d,e,l,t){var a,n=3<arguments.length&&void 0!==t?t:{},r={debounceTime:n.debounceTime||0,interval:n.interval||500,useCapture:n.useCapture||!1},u=0;function o(e){var t="wheel"===f?e:function(e){var t=e||window.event,n={originalEvent:t,timeStamp:t.timeStamp,target:t.target||t.srcElement,type:"wheel",deltaMode:"MozMousePixelScroll"===t.type?0:1,deltaX:0,deltaY:0,deltaZ:0,preventDefault:function(){t.preventDefault?t.preventDefault():t.returnValue=!1}};return"mousewheel"===f?(n.deltaY=-.025*t.wheelDelta,t.wheelDeltaX&&(n.deltaX=-.025*t.wheelDeltaX)):n.deltaY=t.detail,n}(e),n=t.timeStamp-u,o="wheelMove";if(!(n<r.debounceTime)){r.interval<n&&(o="wheelStart");var i=1;1===t.deltaMode?i=function(e){var t=e instanceof Window?document.documentElement:e,n=window.getComputedStyle(t).fontSize||"16px";return parseInt(n)/2}(d):2===t.deltaMode&&(i=window.innerHeight),l({dx:t.deltaX*i||0,dy:t.deltaY*i||0,dz:t.deltaZ*i||0,originalEvent:t,type:o}),u=t.timeStamp,clearTimeout(a),a=setTimeout(function(){l({dx:0,dy:0,dz:0,originalEvent:{timeStamp:t.timeStamp+r.interval},type:"wheelEnd"})},r.interval)}}return(0,d[m])(i+e,o,r.useCapture),function(){(0,d[c])(i+e,o,r.useCapture)}}"undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener?(m="addEventListener",c="removeEventListener"):(m="attachEvent",c="detachEvent",i="on"),f="onwheel"in document.createElement("div")?"wheel":void 0!==window.onmousewheel?"mousewheel":"DOMMouseScroll");return Object.freeze({bind:function(e,t,n){return"function"==typeof e&&(n=t,t=e,e=window),o(e,"DOMMouseScroll"===f?"MozMousePixelScroll":f,t,n)}})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).MouseWheelMouseEvents=t()}(this,function(){"use strict";var i="",d="addEventListener",l="removeEventListener",p="wheel";function o(c,e,v,t){var w,n=3<arguments.length&&void 0!==t?t:{},f={debounceTime:n.debounceTime||0,interval:n.interval||500,useCapture:n.useCapture||!1},s=0;function o(e){var t,n,o,i,d,l,a,r="wheel"===p?e:(t=e||window.event,n={originalEvent:t,timeStamp:t.timeStamp,target:t.target||t.srcElement,type:"wheel",deltaMode:"MozMousePixelScroll"===t.type?0:1,deltaX:0,deltaY:0,deltaZ:0,preventDefault:function(){t.preventDefault?t.preventDefault():t.returnValue=!1}},"mousewheel"===p?(n.deltaY=-.025*t.wheelDelta,t.wheelDeltaX&&(n.deltaX=-.025*t.wheelDeltaX)):n.deltaY=t.detail,n),u=r.timeStamp-s,m="wheelMove";u<f.debounceTime||(f.interval<u&&(m="wheelStart"),(o=1)===r.deltaMode?(d=(i=c)instanceof Window?document.documentElement:i,l=window.getComputedStyle(d).fontSize||"16px",o=parseInt(l,10)):2===r.deltaMode&&(o=window.innerHeight),a="wheelStart"!==m?u:0,v({dx:r.deltaX*o||0,dy:r.deltaY*o||0,dz:r.deltaZ*o||0,dTime:a,originalEvent:r,type:m}),s=r.timeStamp,clearTimeout(w),w=setTimeout(function(){v({dx:0,dy:0,dz:0,dTime:a+f.interval,originalEvent:{timeStamp:r.timeStamp+f.interval},type:"wheelEnd"})},f.interval))}return(0,c[d])(i+e,o,f.useCapture),function(){(0,c[l])(i+e,o,f.useCapture)}}"undefined"!=typeof window&&"undefined"!=typeof document&&("addEventListener"in window?(d="addEventListener",l="removeEventListener"):(d="attachEvent",l="detachEvent",i="on"),p="onwheel"in document.createElement("div")?"wheel":void 0!==window.onmousewheel?"mousewheel":"DOMMouseScroll");return Object.freeze({bind:function(e,t,n){return"function"==typeof e&&(n=t,t=e,e=window),o(e,"DOMMouseScroll"===p?"MozMousePixelScroll":p,t,n)}})}); |
/** | ||
* Bundle of @livelybone/mouse-events | ||
* Generated: 2019-07-31 | ||
* Version: 1.0.0-beta | ||
* Generated: 2020-05-16 | ||
* Version: 1.0.0 | ||
* License: MIT | ||
@@ -9,2 +9,2 @@ * Author: 2631541504@qq.com | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).UtilsMouseEvents={})}(this,function(e){"use strict";var n=t,i=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,o=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino|android|ipad|playbook|silk/i;function t(e){var n=(e=e||{}).ua;return n||"undefined"==typeof navigator||(n=navigator.userAgent),n&&n.headers&&"string"==typeof n.headers["user-agent"]&&(n=n.headers["user-agent"]),"string"==typeof n&&(e.tablet?o.test(n):i.test(n))}t.isMobile=n;var r="",a="addEventListener",d="removeEventListener";"undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener?(a="addEventListener",d="removeEventListener"):(a="attachEvent",d="detachEvent",r="on"));var p=n();e.$addListener=function(e,n,i,o){var t=r+n;return e[a].bind(e)(t,i,o),function(){e[d].bind(e)(t,i,o)}},e.$isMobile=p,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).UtilsMouseEvents={})}(this,function(e){"use strict";var n=r,i=r,o=r,t=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,a=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino|android|ipad|playbook|silk/i;function r(e){var n=(e=e||{}).ua;if(n||"undefined"==typeof navigator||(n=navigator.userAgent),n&&n.headers&&"string"==typeof n.headers["user-agent"]&&(n=n.headers["user-agent"]),"string"!=typeof n)return!1;var i=e.tablet?a.test(n):t.test(n);return!i&&e.tablet&&e.featureDetect&&navigator&&1<navigator.maxTouchPoints&&-1!==n.indexOf("Macintosh")&&-1!==n.indexOf("Safari")&&(i=!0),i}n.isMobile=i,n.default=o;var d=i(),p="",s="addEventListener",f="removeEventListener";"undefined"!=typeof window&&"undefined"!=typeof document&&("addEventListener"in window?(s="addEventListener",f="removeEventListener"):(s="attachEvent",f="detachEvent",p="on")),e.$addListener=function(e,n,i,o){var t=p+n;return e[s].bind(e)(t,i,o),function(){e[f].bind(e)(t,i,o)}},e.$isMobile=d,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "@livelybone/mouse-events", | ||
"version": "1.0.0-beta", | ||
"description": "Some reencapsulated mouse events, such as dragmove with deltaX/deltaY relative to mousedown, mouse wheel with good compatibility ...", | ||
"version": "1.0.0", | ||
"description": "Some complex mouse events, such as dragMove event with deltaX/deltaY relative to mousedown/touchstart, mouse wheel with good compatibility ...", | ||
"main": "./lib/umd/index.js", | ||
@@ -10,3 +10,6 @@ "module": "./lib/es/index.js", | ||
"scripts": { | ||
"build": "rimraf ./lib && cross-env NODE_ENV=production rollup -c", | ||
"build:js": "cross-env NODE_ENV=production rollup -c", | ||
"build:dts": "cross-env NODE_ENV=production BUILD_ENV=dts rollup -c", | ||
"dev": "rimraf ./lib && cross-env BUILD_ENV=watch node watch.js", | ||
"build": "rimraf ./lib && npm run build:js", | ||
"build:test": "rimraf ./test-lib && cross-env NODE_ENV=test rollup -c rollup.config.test.js --sourcemap", | ||
@@ -20,9 +23,8 @@ "eslint": "eslint ./ --ext .ts,.js --fix", | ||
"type": "git", | ||
"url": "git@github.com:livelybone/mouse-events.git" | ||
"url": "https://github.com/livelybone/mouse-events.git" | ||
}, | ||
"keywords": [ | ||
"mouse event", | ||
"touch event", | ||
"dragmove", | ||
"deltaX", | ||
"deltaY", | ||
"mouse wheel" | ||
@@ -38,2 +40,3 @@ ], | ||
"@babel/core": "^7.5.0", | ||
"@babel/plugin-proposal-class-properties": "^7.5.5", | ||
"@babel/plugin-transform-runtime": "^7.5.0", | ||
@@ -43,2 +46,3 @@ "@babel/preset-env": "^7.5.0", | ||
"@babel/runtime": "^7.5.1", | ||
"@livelybone/singleton": "^1.1.1", | ||
"@typescript-eslint/eslint-plugin": "^1.12.0", | ||
@@ -48,5 +52,8 @@ "@typescript-eslint/parser": "^1.11.0", | ||
"chai": "^4.2.0", | ||
"chalk": "^2.4.2", | ||
"chokidar": "^3.0.2", | ||
"commitizen": "^3.0.7", | ||
"conventional-changelog-cli": "^2.0.12", | ||
"cross-env": "^5.2.0", | ||
"cross-spawn": "^6.0.5", | ||
"cz-conventional-changelog": "^2.1.0", | ||
@@ -58,2 +65,3 @@ "eslint": "^5.3.0", | ||
"eslint-plugin-prettier": "^3.1.0", | ||
"express": "^4.17.1", | ||
"husky": "^3.0.0", | ||
@@ -64,3 +72,3 @@ "istanbul": "^1.1.0-alpha.1", | ||
"prettier": "^1.18.2", | ||
"rollup": "^1.7.0", | ||
"rollup": "1.7.0", | ||
"rollup-plugin-babel": "^4.3.3", | ||
@@ -95,5 +103,5 @@ "rollup-plugin-commonjs": "^9.2.1", | ||
"dependencies": { | ||
"@livelybone/mouse-wheel": "^4.1.0", | ||
"@livelybone/mouse-wheel": "^4.2.1", | ||
"is-mobile": "^2.0.1" | ||
} | ||
} |
# @livelybone/mouse-events | ||
[![NPM Version](http://img.shields.io/npm/v/@livelybone/mouse-events.svg?style=flat-square)](https://www.npmjs.com/package/@livelybone/mouse-events) | ||
[![Download Month](http://img.shields.io/npm/dm/@livelybone/mouse-events.svg?style=flat-square)](https://www.npmjs.com/package/@livelybone/mouse-events) | ||
![gzip with dependencies: 2.1kb](https://img.shields.io/badge/gzip--with--dependencies-2.1kb-brightgreen.svg "gzip with dependencies: 2.1kb") | ||
![gzip with dependencies: kb](https://img.shields.io/badge/gzip--with--dependencies-kb-brightgreen.svg "gzip with dependencies: kb") | ||
![typescript](https://img.shields.io/badge/typescript-supported-blue.svg "typescript") | ||
@@ -10,6 +10,8 @@ ![pkg.module](https://img.shields.io/badge/pkg.module-supported-blue.svg "pkg.module") | ||
Some reencapsulated mouse events, such as dragmove with deltaX/deltaY relative to mousedown, mouse wheel with good compatibility ... | ||
[中文文档](./README-CN.md) | ||
Some complex mouse events, such as dragMove event with deltaX/deltaY relative to mousedown/touchstart, mouse wheel with good compatibility ... | ||
## repository | ||
git@github.com:livelybone/mouse-events.git | ||
https://github.com/livelybone/mouse-events.git | ||
@@ -19,2 +21,11 @@ ## Demo | ||
## Run Example | ||
you can see the usage by run the example of the module, here is the step: | ||
1. Clone the library `git clone https://github.com/livelybone/mouse-events.git` | ||
2. Go to the directory `cd your-module-directory` | ||
3. Install npm dependencies `npm i`(use taobao registry: `npm i --registry=http://registry.npm.taobao.org`) | ||
4. Open service `npm run dev` | ||
5. See the example(usually is `http://127.0.0.1:3000/examples/test.html`) in your browser | ||
## Installation | ||
@@ -25,11 +36,34 @@ ```bash | ||
## Global name | ||
## Global name - The variable the module exported in `umd` bundle | ||
`MouseEvents` | ||
## Interface | ||
See what method or params you can use in [index.d.ts](./index.d.ts) | ||
## Usage | ||
```js | ||
import * as MouseEvents from '@livelybone/mouse-events' | ||
```typescript | ||
import { DragMove, Utils, MouseWheel, DragMoveEvent } from '@livelybone/mouse-events' | ||
const el = document.getElementById('el') | ||
let removeListener | ||
removeListener = MouseWheel.bind(el, (ev: MouseWheel.CustomWheelEvent) => { | ||
// ... | ||
}) | ||
removeListener() | ||
removeListener = DragMove.bind(el, (ev: DragMoveEvent) => { | ||
// ... | ||
}) | ||
removeListener() | ||
console.log(Utils.$isMobile) | ||
removeListener = Utils.$addListener(el, 'scroll', ev => { | ||
// ... | ||
}) | ||
removeListener() | ||
``` | ||
Use in html, see what your can use in [CDN: unpkg](https://unpkg.com/@livelybone/mouse-events/lib/umd/) | ||
## CDN | ||
Use in html, see what you can use in [CDN: unpkg](https://unpkg.com/@livelybone/mouse-events/lib/umd/) | ||
```html | ||
@@ -39,1 +73,6 @@ <-- use what you want --> | ||
``` | ||
Or,see what you can use in [CDN: jsdelivr](https://cdn.jsdelivr.net/npm/@livelybone/mouse-events/lib/umd/) | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/@livelybone/mouse-events/lib/umd/<--module-->.js"></script> | ||
``` |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
32072
11
346
0
75
37