dragselect
Advanced tools
Comparing version 1.3.3 to 1.3.4
@@ -283,2 +283,3 @@ /* | ||
function toArray(obj) { | ||
if(!obj) { return false; } | ||
if(!obj.length && isElement(obj)) { return [obj]; } | ||
@@ -285,0 +286,0 @@ |
@@ -1,1 +0,1 @@ | ||
var dragSelect=function(e){function t(e){for(var t=y(e),n=0,o=t.length;n<o;n++){var l=t[n];g.indexOf(l)<0&&g.push(l)}}function n(e){for(var t=y(e),n=0,o=t.length;n<o;n++){var l=t[n];g.indexOf(l)>0&&(f(l,"selected"),g.splice(g.indexOf(l),1))}}function o(){document.addEventListener("mousedown",l)}function l(e){b={x:e.pageX||e.clientX,y:e.pageY||e.clientY},p.style.display="block",p.style.top=b.y+"px",p.style.left=b.x+"px",s(),document.addEventListener("mousemove",c),document.addEventListener("mouseup",i)}function c(e){E={x:e.pageX||e.clientX,y:e.pageY||e.clientY},E.x>b.x?p.style.width=E.x-b.x+"px":(p.style.left=E.x+"px",p.style.width=b.x-E.x+"px"),E.y>b.y?p.style.height=E.y-b.y+"px":(p.style.top=E.y+"px",p.style.height=b.y-E.y+"px"),s()}function s(){for(var e=0,t=g.length;e<t;e++){var n=g[e],o=w.indexOf(n);r(n,p)?o<0&&(w.push(n),u(n,"selected"),h(n)):o>-1&&(w.splice(w.indexOf(n),1),f(n,"selected"),x(n))}}function i(){p.style.width="0",p.style.height="0",p.style.display="none",document.removeEventListener("mousemove",c),v(w)}function r(e,t){var n={x:window.scrollY||document.documentElement.scrollTop,y:window.scrollX||document.documentElement.scrollLeft},o={y:t.getBoundingClientRect().top+n.y,x:t.getBoundingClientRect().left+n.x,h:t.offsetHeight,w:t.offsetWidth},l={y:e.getBoundingClientRect().top+n.y,x:e.getBoundingClientRect().left+n.x,h:e.offsetHeight,w:e.offsetWidth};return o.x<l.x+l.w&&o.x+o.w>l.x&&o.y<l.y+l.h&&o.h+o.y>l.y}function a(){return w}function d(){i(),document.removeEventListener("mousedown",l)}function u(e,t){var n=e.className;-1===n.indexOf(t)&&(""!==n&&(t=" "+t),e.className=n+t)}function f(e,t){var n=e.className;new RegExp(t+"\\b","g");n=n.replace(t,""),e.className=n}function y(e){if(!e.length&&m(e))return[e];for(var t=[],n=e.length-1;n>=0;n--)t[n]=e[n];return t}function m(e){try{return e instanceof HTMLElement}catch(t){return"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument}}e?e&&!e.selectables&&console.log("ERROR: dragSelect: please provide nodes that can be selected. See reference at: https://github.com/ThibaultJanBeyer/dragSelect for more info"):console.log("ERROR: dragSelect: please provide an options object to the function. See reference at: https://github.com/ThibaultJanBeyer/dragSelect for more info");var p=e.selector||document.getElementById("rectangle"),g=y(e.selectables)||[],h=e.onElementSelect||function(){},x=e.onElementUnselect||function(){},v=e.callback||function(){},w=[];o();var b,E;return{removeClass:f,addClass:u,stop:d,isElementTouching:r,reset:i,checkIfInside:s,move:c,startUp:l,start:o,getSelection:a,removeSelectables:n,addSelectables:t}};"undefined"!=typeof module&&null!==module?module.exports=dragSelect:window.dragSelect=dragSelect; | ||
var dragSelect=function(e){function t(e){for(var t=y(e),n=0,o=t.length;n<o;n++){var l=t[n];g.indexOf(l)<0&&g.push(l)}}function n(e){for(var t=y(e),n=0,o=t.length;n<o;n++){var l=t[n];g.indexOf(l)>0&&(f(l,"selected"),g.splice(g.indexOf(l),1))}}function o(){document.addEventListener("mousedown",l)}function l(e){b={x:e.pageX||e.clientX,y:e.pageY||e.clientY},p.style.display="block",p.style.top=b.y+"px",p.style.left=b.x+"px",s(),document.addEventListener("mousemove",c),document.addEventListener("mouseup",i)}function c(e){E={x:e.pageX||e.clientX,y:e.pageY||e.clientY},E.x>b.x?p.style.width=E.x-b.x+"px":(p.style.left=E.x+"px",p.style.width=b.x-E.x+"px"),E.y>b.y?p.style.height=E.y-b.y+"px":(p.style.top=E.y+"px",p.style.height=b.y-E.y+"px"),s()}function s(){for(var e=0,t=g.length;e<t;e++){var n=g[e],o=w.indexOf(n);r(n,p)?o<0&&(w.push(n),u(n,"selected"),h(n)):o>-1&&(w.splice(w.indexOf(n),1),f(n,"selected"),x(n))}}function i(){p.style.width="0",p.style.height="0",p.style.display="none",document.removeEventListener("mousemove",c),v(w)}function r(e,t){var n={x:window.scrollY||document.documentElement.scrollTop,y:window.scrollX||document.documentElement.scrollLeft},o={y:t.getBoundingClientRect().top+n.y,x:t.getBoundingClientRect().left+n.x,h:t.offsetHeight,w:t.offsetWidth},l={y:e.getBoundingClientRect().top+n.y,x:e.getBoundingClientRect().left+n.x,h:e.offsetHeight,w:e.offsetWidth};return o.x<l.x+l.w&&o.x+o.w>l.x&&o.y<l.y+l.h&&o.h+o.y>l.y}function a(){return w}function d(){i(),document.removeEventListener("mousedown",l)}function u(e,t){var n=e.className;-1===n.indexOf(t)&&(""!==n&&(t=" "+t),e.className=n+t)}function f(e,t){var n=e.className;new RegExp(t+"\\b","g");n=n.replace(t,""),e.className=n}function y(e){if(!e)return!1;if(!e.length&&m(e))return[e];for(var t=[],n=e.length-1;n>=0;n--)t[n]=e[n];return t}function m(e){try{return e instanceof HTMLElement}catch(t){return"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument}}e?e&&!e.selectables&&console.log("ERROR: dragSelect: please provide nodes that can be selected. See reference at: https://github.com/ThibaultJanBeyer/dragSelect for more info"):console.log("ERROR: dragSelect: please provide an options object to the function. See reference at: https://github.com/ThibaultJanBeyer/dragSelect for more info");var p=e.selector||document.getElementById("rectangle"),g=y(e.selectables)||[],h=e.onElementSelect||function(){},x=e.onElementUnselect||function(){},v=e.callback||function(){},w=[];o();var b,E;return{removeClass:f,addClass:u,stop:d,isElementTouching:r,reset:i,checkIfInside:s,move:c,startUp:l,start:o,getSelection:a,removeSelectables:n,addSelectables:t}};"undefined"!=typeof module&&null!==module?module.exports=dragSelect:window.dragSelect=dragSelect; |
{ | ||
"name": "dragselect", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "easy javascript drag select functionality to your projects", | ||
@@ -5,0 +5,0 @@ "main": "./dist/ds.min.js", |
@@ -56,3 +56,3 @@ ``` | ||
The rectangle has to have a `position: fixed` attribute. The other ones have purely visual reasons. | ||
The rectangle has to have a `position: fixed/absolute` attribute. The other ones have purely visual reasons. | ||
```html | ||
@@ -59,0 +59,0 @@ <div id="rectangle" |
@@ -283,2 +283,3 @@ /* | ||
function toArray(obj) { | ||
if(!obj) { return false; } | ||
if(!obj.length && isElement(obj)) { return [obj]; } | ||
@@ -285,0 +286,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1116818
835