UNPKG

dom-mousemove-dispatcher

Version:
1 lines 1.72 kB
var mouseMoveDispatcher=function(){"use strict";function e(e){function o(e){for(var t=0;t<c.length;t++)u[c[t]]=e[c[t]]}function r(){e&&e.removeEventListener("mousemove",o,!1),u=null}var u={screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:!1,shiftKey:!1,altKey:!1,metaKey:!1,button:0,buttons:1,relatedTarget:null,region:null};void 0!==e&&e.addEventListener("mousemove",o);var i=function(){return MouseEvent?function(e,o,r){var c=new MouseEvent("mousemove",t(u,o));return n(c,r),e.dispatchEvent(c)}:"function"==typeof document.createEvent?function(e,o,r){var c=t(u,o),i=document.createEvent("MouseEvents");return i.initMouseEvent("mousemove",!0,!0,window,0,c.screenX,c.screenY,c.clientX,c.clientY,c.ctrlKey,c.altKey,c.shiftKey,c.metaKey,c.button,c.relatedTarget),n(i,r),e.dispatchEvent(i)}:"function"==typeof document.createEventObject?function(e,o,r){var c=document.createEventObject(),i=t(u,o);for(var a in i)c[a]=i[a];return n(c,r),e.dispatchEvent(c)}:void 0}();return{destroy:r,dispatch:i}}function t(e,t){t=t||{};for(var n=r(e),o=0;o<c.length;o++)void 0!==t[c[o]]&&(n[c[o]]=t[c[o]]);return n}function n(e,t){console.log("data ",t),e.data=t||{},e.dispatched="mousemove"}var o=void 0;o="function"!=typeof Object.create?function(e){var t=function(){};return function(n,o){if(n!==Object(n)&&null!==n)throw TypeError("Argument must be an object, or null");t.prototype=n||{};var r=new t;return t.prototype=null,o!==e&&Object.defineProperties(r,o),null===n&&(r.__proto__=null),r}}():Object.create;var r=o,c=["altKey","button","buttons","clientX","clientY","ctrlKey","metaKey","movementX","movementY","offsetX","offsetY","pageX","pageY","region","relatedTarget","screenX","screenY","shiftKey","which","x","y"];return e}();