find-my-el
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -0,1 +1,8 @@ | ||
/*! | ||
* find-my-el - Locates the DOM element closest to a given set of coordinates | ||
* @version 1.1.4 | ||
* | ||
* @copyright Collin Henderson <collin@syropia.net> | ||
* @license MIT | ||
*/ | ||
'use strict'; | ||
@@ -2,0 +9,0 @@ |
@@ -0,1 +1,8 @@ | ||
/*! | ||
* find-my-el - Locates the DOM element closest to a given set of coordinates | ||
* @version 1.1.4 | ||
* | ||
* @copyright Collin Henderson <collin@syropia.net> | ||
* @license MIT | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.findMyEl=e()}(this,function(){"use strict";function t(t,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r={container:window,axis:"both"},i=Object.assign({},r,o),a=0,c=0,u=0,f={top:0,left:0},s=[],l=i.container===window?window.innerWidth:i.container.clientWidth,d=i.container===window?window.innerHeight:i.container.clientHeight;if(i.container!==window){var w=i.container.getBoundingClientRect();f.left=w.left+document.body.scrollLeft,f.top=w.top+document.body.scrollTop}if(t.constructor===Array){if(t[0]<0||t[1]<0)throw new Error("Coordinates cannot be negative values");a=t[0],c=t[1]}else{if("string"!=typeof t)throw new Error("Invalid position");switch(t){case"CENTER":a=l/2,c=d/2;break;case"LEFT_TOP":a=0,c=0;break;case"RIGHT_TOP":a=l,c=0;break;case"CENTER_TOP":a=l/2,c=0;break;case"LEFT_CENTER":a=0,c=d/2;break;case"LEFT_BOTTOM":a=0,c=d;break;case"RIGHT_BOTTOM":a=l,c=d;break;case"CENTER_BOTTOM":a=l/2,c=d;break;case"RIGHT_CENTER":a=l,c=d/2;break;default:a=l/2,c=d/2}}return[].concat(e(n)).forEach(function(t){var e=0,n=t.getBoundingClientRect(),o={left:n.left+(i.container===window?document.body.scrollLeft:-f.left),top:n.top+(i.container===window?document.body.scrollTop:-f.top)};e="x"===i.axis.toLowerCase()?Math.pow(o.left-a,2):"y"===i.axis.toLowerCase()?Math.pow(o.top-c,2):Math.pow(o.left-a,2)+Math.pow(o.top-c,2),s.push(e)}),u=s.indexOf(Math.min.apply(Math,s)),n[u]}var e=(function(){function t(t){this.value=t}function e(e){function n(t,e){return new Promise(function(n,r){var c={key:t,arg:e,resolve:n,reject:r,next:null};a?a=a.next=c:(i=a=c,o(t,e))})}function o(n,i){try{var a=e[n](i),c=a.value;c instanceof t?Promise.resolve(c.value).then(function(t){o("next",t)},function(t){o("throw",t)}):r(a.done?"return":"normal",a.value)}catch(t){r("throw",t)}}function r(t,e){switch(t){case"return":i.resolve({value:e,done:!0});break;case"throw":i.reject(e);break;default:i.resolve({value:e,done:!1})}i=i.next,i?o(i.key,i.arg):a=null}var i,a;this._invoke=n,"function"!=typeof e.return&&(this.return=void 0)}return"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)},{wrap:function(t){return function(){return new e(t.apply(this,arguments))}},await:function(e){return new t(e)}}}(),function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)});return t}); |
{ | ||
"name": "find-my-el", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Locates the DOM element closest to a given set of coordinates", | ||
@@ -13,3 +13,4 @@ "main": "index.js", | ||
"build:umd": "BUILD_ENV=umd rollup -c && cp index.umd.js demo", | ||
"test": "karma start karma.conf.js --single-run true --auto-watch false" | ||
"test": "karma start karma.conf.js --single-run true --auto-watch false", | ||
"version": "npm run build:all" | ||
}, | ||
@@ -16,0 +17,0 @@ "keywords": [ |
12926
259