Comparing version 0.0.2 to 0.0.3
export declare const PROPERTIES: readonly ["selectableTargets", "continueSelect", "hitRate"]; | ||
export declare const EVENTS: readonly ["selectStart", "select", "selectEnd"]; | ||
export declare const EVENTS: readonly ["dragStart", "selectStart", "select", "selectEnd"]; |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/selecto.git | ||
version: 0.0.2 | ||
version: 0.0.3 | ||
*/ | ||
@@ -228,2 +228,10 @@ 'use strict'; | ||
var type = inputEvent.type; | ||
var isTrusted = type === "mousedown" || type === "touchstart"; | ||
var result = isTrusted ? _this.trigger("dragStart", e) : true; | ||
if (!result) { | ||
return false; | ||
} | ||
_this.select(firstPassedTargets, inputEvent, true); | ||
@@ -230,0 +238,0 @@ |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/selecto.git | ||
version: 0.0.2 | ||
version: 0.0.3 | ||
*/ | ||
@@ -226,2 +226,10 @@ import Component from '@egjs/component'; | ||
var type = inputEvent.type; | ||
var isTrusted = type === "mousedown" || type === "touchstart"; | ||
var result = isTrusted ? _this.trigger("dragStart", e) : true; | ||
if (!result) { | ||
return false; | ||
} | ||
_this.select(firstPassedTargets, inputEvent, true); | ||
@@ -228,0 +236,0 @@ |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/selecto.git | ||
version: 0.0.2 | ||
version: 0.0.3 | ||
*/ | ||
@@ -225,2 +225,10 @@ (function (global, factory) { | ||
var type = inputEvent.type; | ||
var isTrusted = type === "mousedown" || type === "touchstart"; | ||
var result = isTrusted ? _this.trigger("dragStart", e) : true; | ||
if (!result) { | ||
return false; | ||
} | ||
_this.select(firstPassedTargets, inputEvent, true); | ||
@@ -227,0 +235,0 @@ |
@@ -7,5 +7,5 @@ /* | ||
repository: git+https://github.com/daybrush/selecto.git | ||
version: 0.0.2 | ||
version: 0.0.3 | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@egjs/component"),require("@daybrush/drag"),require("css-styled"),require("framework-utils"),require("@daybrush/utils"),require("@egjs/children-differ")):"function"==typeof define&&define.amd?define(["@egjs/component","@daybrush/drag","css-styled","framework-utils","@daybrush/utils","@egjs/children-differ"],e):(t=t||self).Selecto=e(t.Component,t.Dragger,t.styled,t.frameworkUtils,t.utils,t.ChildrenDiffer)}(this,function(t,a,e,o,g,p){"use strict";var c=function(t,e){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var l=function(){return(l=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function u(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=e||{},s=i.className,a=i.style;return{tag:t,className:void 0===s?"":s,style:void 0===a?{}:a,attributes:function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(i,["className","style"]),children:n}}var d=["selectableTargets","continueSelect","hitRate"],f=e("\n:host {\n position: absolute;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n");return function(e){function t(){this.constructor=n}var n,r;function i(t){void 0===t&&(t={});var h=e.call(this)||this;return h.selectedTargets=[],h.differ=new p,h.onDragStart=function(t){var e=t.datas,n=t.clientX,r=t.clientY,i=t.inputEvent,s=h.options,a=s.continueSelect,o=s.selectOutside,c=h.getSelectableTargets(),l=c.map(function(t){var e=t.getBoundingClientRect(),n=e.left,r=e.top;return{left:n,top:r,right:n+e.width,bottom:r+e.height}});e.selectableTargets=c,e.selectableRects=l,e.startSelectedTargets=h.selectedTargets;var u=document.elementFromPoint(n,r),d=h.hitTest({left:n,top:r,right:n,bottom:r},n,r,c,l).filter(function(t){return t===u||t.contains(u)}),f=0<d.length;return a?d=h.getSelectedTargets(d):h.selectedTargets=[],h.select(d,i,!0),e.startX=n,e.startY=r,e.selectedTargets=d,h.target.style.cssText+="left:"+n+"px;top:"+r+"px",!o||!f||(h.onDragEnd(t),!1)},h.onDrag=function(t){var e=t.distX,n=t.distY,r=t.datas,i=t.inputEvent,s=r.startX,a=r.startY,o=Math.min(0,e),c=Math.min(0,n),l=Math.abs(e),u=Math.abs(n);h.target.style.cssText+="display: block;transform: translate("+o+"px, "+c+"px);width:"+l+"px;height:"+u+"px;";var d=s+o,f=a+c,g=h.hitTest({left:d,top:f,right:d+l,bottom:f+u},r.startX,r.startY,r.selectableTargets,r.selectableRects),p=h.getSelectedTargets(g);h.select(p,i),r.selectedTargets=p},h.onDragEnd=function(t){var e=t.datas,n=t.inputEvent;h.target.style.cssText+="display: none;",h.selecteEnd(e.startSelectedTargets,e.selectedTargets,n),h.selectedTargets=e.selectedTargets},h.target=t.target,h.container=t.container,h.options=l({target:null,container:null,dragContainer:null,selectableTargets:[],selectByClick:!0,selectOutside:!1,hitRate:100,continueSelect:!1},t),h.initElement(),h}c(n=i,r=e),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t);var s=i.prototype;return s.destroy=function(){this.dragger.unset(),this.injectResult.destroy(),this.dragger=null,this.injectResult=null,this.target=null,this.container=null,this.options=null},s.click=function(t){var e=function(t){if("touches"in t){var e=t.touches[0];return{clientX:e.clientX,clientY:e.clientY}}return{clientX:t.clientX,clientY:t.clientY}}(t),n={datas:{},clientX:e.clientX,clientY:e.clientY,inputEvent:t};this.onDragStart(n)&&this.onDragEnd(n)},s.initElement=function(){this.target=function n(t,e,r){var i=t.tag,s=t.children,a=t.attributes,o=t.className,c=t.style,l=e||document.createElement(i);for(var u in a)l.setAttribute(u,a[u]);var d=l.children;if(s.forEach(function(t,e){n(t,d[e],l)}),o&&o.split(" ").forEach(function(t){g.hasClass(l,t)||g.addClass(l,t)}),c){var f=l.style;for(var u in c)f[u]=c[u]}return!e&&r&&r.appendChild(l),l}(u("div",{className:"selecto-selection "+f.className}),this.target,this.container);var t=this.target;this.dragger=new a(this.options.dragContainer||this.target.parentElement,{container:window,dragstart:this.onDragStart,drag:this.onDrag,dragend:this.onDragEnd}),this.injectResult=f.inject(t)},s.hitTest=function(t,g,p,h,e){var n=this.options,v=n.hitRate,m=n.selectByClick,y=t.left,b=t.top,T=t.right,E=t.bottom,O=[];return e.forEach(function(t,e){var n=t.left,r=t.top,i=t.right,s=t.bottom,a=n<=g&&g<=i&&r<=p&&p<=s,o=(i-n)*(s-r),c=Math.max(n,y),l=Math.min(i,T),u=Math.max(r,b),d=Math.min(s,E);if(m&&a)O.push(h[e]);else if(!(l<c||d<u)){var f=Math.round((l-c)*(d-u)/o*100);v<=f&&O.push(h[e])}}),O},s.getSelectableTargets=function(){var e=[];return this.options.selectableTargets.forEach(function(t){g.isObject(t)?e.push(t):[].slice.call(document.querySelectorAll(t)).forEach(function(t){e.push(t)})}),e},s.getSelectedTargets=function(t){var e=p.diff(this.selectedTargets,t),n=e.list,r=e.prevList,i=e.added,s=e.removed;return i.map(function(t){return n[t]}).concat(s.map(function(t){return r[t]}))},s.select=function(t,e,n){var r=this.differ.update(t),i=r.added,s=r.removed,a=r.prevList,o=r.list;n&&this.trigger("selectStart",{selected:t,added:i.map(function(t){return o[t]}),removed:s.map(function(t){return a[t]}),inputEvent:e}),(i.length||s.length)&&this.trigger("select",{selected:t,added:i.map(function(t){return o[t]}),removed:s.map(function(t){return a[t]}),inputEvent:e})},s.selecteEnd=function(t,e,n){var r=p.diff(t,e),i=r.added,s=r.removed,a=r.prevList,o=r.list,c=p.diff(this.selectedTargets,e),l=c.added,u=c.removed,d=c.prevList,f=c.list;this.trigger("selectEnd",{selected:e,added:i.map(function(t){return o[t]}),removed:s.map(function(t){return a[t]}),afterAdded:l.map(function(t){return f[t]}),afterRemoved:u.map(function(t){return d[t]}),inputEvent:n})},i=function(t,e,n,r){var i,s=arguments.length,a=s<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var o=t.length-1;0<=o;o--)(i=t[o])&&(a=(s<3?i(a):3<s?i(e,n,a):i(e,n))||a);return 3<s&&a&&Object.defineProperty(e,n,a),a}([o.Properties(d,function(t,e){Object.defineProperty(t,e,{get:function(){return this.options[e]},set:function(t){this.options[e]=t},enumerable:!0,configurable:!0})})],i)}(t)}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@egjs/component"),require("@daybrush/drag"),require("css-styled"),require("framework-utils"),require("@daybrush/utils"),require("@egjs/children-differ")):"function"==typeof define&&define.amd?define(["@egjs/component","@daybrush/drag","css-styled","framework-utils","@daybrush/utils","@egjs/children-differ"],e):(t=t||self).Selecto=e(t.Component,t.Dragger,t.styled,t.frameworkUtils,t.utils,t.ChildrenDiffer)}(this,function(t,s,e,o,g,p){"use strict";var c=function(t,e){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};var l=function(){return(l=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function u(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=e||{},a=i.className,s=i.style;return{tag:t,className:void 0===a?"":a,style:void 0===s?{}:s,attributes:function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(i,["className","style"]),children:r}}var d=["selectableTargets","continueSelect","hitRate"],f=e("\n:host {\n position: absolute;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n");return function(e){function t(){this.constructor=r}var r,n;function i(t){void 0===t&&(t={});var h=e.call(this)||this;return h.selectedTargets=[],h.differ=new p,h.onDragStart=function(t){var e=t.datas,r=t.clientX,n=t.clientY,i=t.inputEvent,a=h.options,s=a.continueSelect,o=a.selectOutside,c=h.getSelectableTargets(),l=c.map(function(t){var e=t.getBoundingClientRect(),r=e.left,n=e.top;return{left:r,top:n,right:r+e.width,bottom:n+e.height}});e.selectableTargets=c,e.selectableRects=l,e.startSelectedTargets=h.selectedTargets;var u=document.elementFromPoint(r,n),d=h.hitTest({left:r,top:n,right:r,bottom:n},r,n,c,l).filter(function(t){return t===u||t.contains(u)}),f=0<d.length;s?d=h.getSelectedTargets(d):h.selectedTargets=[];var g=i.type;return!(("mousedown"===g||"touchstart"===g)&&!h.trigger("dragStart",t))&&(h.select(d,i,!0),e.startX=r,e.startY=n,e.selectedTargets=d,h.target.style.cssText+="left:"+r+"px;top:"+n+"px",!o||!f||(h.onDragEnd(t),!1))},h.onDrag=function(t){var e=t.distX,r=t.distY,n=t.datas,i=t.inputEvent,a=n.startX,s=n.startY,o=Math.min(0,e),c=Math.min(0,r),l=Math.abs(e),u=Math.abs(r);h.target.style.cssText+="display: block;transform: translate("+o+"px, "+c+"px);width:"+l+"px;height:"+u+"px;";var d=a+o,f=s+c,g=h.hitTest({left:d,top:f,right:d+l,bottom:f+u},n.startX,n.startY,n.selectableTargets,n.selectableRects),p=h.getSelectedTargets(g);h.select(p,i),n.selectedTargets=p},h.onDragEnd=function(t){var e=t.datas,r=t.inputEvent;h.target.style.cssText+="display: none;",h.selecteEnd(e.startSelectedTargets,e.selectedTargets,r),h.selectedTargets=e.selectedTargets},h.target=t.target,h.container=t.container,h.options=l({target:null,container:null,dragContainer:null,selectableTargets:[],selectByClick:!0,selectOutside:!1,hitRate:100,continueSelect:!1},t),h.initElement(),h}c(r=i,n=e),r.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t);var a=i.prototype;return a.destroy=function(){this.dragger.unset(),this.injectResult.destroy(),this.dragger=null,this.injectResult=null,this.target=null,this.container=null,this.options=null},a.click=function(t){var e=function(t){if("touches"in t){var e=t.touches[0];return{clientX:e.clientX,clientY:e.clientY}}return{clientX:t.clientX,clientY:t.clientY}}(t),r={datas:{},clientX:e.clientX,clientY:e.clientY,inputEvent:t};this.onDragStart(r)&&this.onDragEnd(r)},a.initElement=function(){this.target=function r(t,e,n){var i=t.tag,a=t.children,s=t.attributes,o=t.className,c=t.style,l=e||document.createElement(i);for(var u in s)l.setAttribute(u,s[u]);var d=l.children;if(a.forEach(function(t,e){r(t,d[e],l)}),o&&o.split(" ").forEach(function(t){g.hasClass(l,t)||g.addClass(l,t)}),c){var f=l.style;for(var u in c)f[u]=c[u]}return!e&&n&&n.appendChild(l),l}(u("div",{className:"selecto-selection "+f.className}),this.target,this.container);var t=this.target;this.dragger=new s(this.options.dragContainer||this.target.parentElement,{container:window,dragstart:this.onDragStart,drag:this.onDrag,dragend:this.onDragEnd}),this.injectResult=f.inject(t)},a.hitTest=function(t,g,p,h,e){var r=this.options,v=r.hitRate,m=r.selectByClick,y=t.left,b=t.top,T=t.right,E=t.bottom,O=[];return e.forEach(function(t,e){var r=t.left,n=t.top,i=t.right,a=t.bottom,s=r<=g&&g<=i&&n<=p&&p<=a,o=(i-r)*(a-n),c=Math.max(r,y),l=Math.min(i,T),u=Math.max(n,b),d=Math.min(a,E);if(m&&s)O.push(h[e]);else if(!(l<c||d<u)){var f=Math.round((l-c)*(d-u)/o*100);v<=f&&O.push(h[e])}}),O},a.getSelectableTargets=function(){var e=[];return this.options.selectableTargets.forEach(function(t){g.isObject(t)?e.push(t):[].slice.call(document.querySelectorAll(t)).forEach(function(t){e.push(t)})}),e},a.getSelectedTargets=function(t){var e=p.diff(this.selectedTargets,t),r=e.list,n=e.prevList,i=e.added,a=e.removed;return i.map(function(t){return r[t]}).concat(a.map(function(t){return n[t]}))},a.select=function(t,e,r){var n=this.differ.update(t),i=n.added,a=n.removed,s=n.prevList,o=n.list;r&&this.trigger("selectStart",{selected:t,added:i.map(function(t){return o[t]}),removed:a.map(function(t){return s[t]}),inputEvent:e}),(i.length||a.length)&&this.trigger("select",{selected:t,added:i.map(function(t){return o[t]}),removed:a.map(function(t){return s[t]}),inputEvent:e})},a.selecteEnd=function(t,e,r){var n=p.diff(t,e),i=n.added,a=n.removed,s=n.prevList,o=n.list,c=p.diff(this.selectedTargets,e),l=c.added,u=c.removed,d=c.prevList,f=c.list;this.trigger("selectEnd",{selected:e,added:i.map(function(t){return o[t]}),removed:a.map(function(t){return s[t]}),afterAdded:l.map(function(t){return f[t]}),afterRemoved:u.map(function(t){return d[t]}),inputEvent:r})},i=function(t,e,r,n){var i,a=arguments.length,s=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;0<=o;o--)(i=t[o])&&(s=(a<3?i(s):3<a?i(e,r,s):i(e,r))||s);return 3<a&&s&&Object.defineProperty(e,r,s),s}([o.Properties(d,function(t,e){Object.defineProperty(t,e,{get:function(){return this.options[e]},set:function(t){this.options[e]=t},enumerable:!0,configurable:!0})})],i)}(t)}); | ||
//# sourceMappingURL=selecto.min.js.map |
@@ -7,5 +7,5 @@ /* | ||
repository: git+https://github.com/daybrush/selecto.git | ||
version: 0.0.2 | ||
version: 0.0.3 | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Selecto=e()}(this,function(){"use strict";var c=function(t,e){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var l=function(){return(l=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function a(t){return void 0===t}var t=function(){var t=function(){function t(){this._eventHandler={},this.options={}}var e=t.prototype;return e.trigger=function(t,e){void 0===e&&(e={});var n=this._eventHandler[t]||[];if(!(0<n.length))return!0;n=n.concat(),e.eventType=t;var i=!1,r=[e],s=0;e.stop=function(){i=!0},e.currentTarget=this;for(var o=arguments.length,a=new Array(2<o?o-2:0),c=2;c<o;c++)a[c-2]=arguments[c];for(1<=a.length&&(r=r.concat(a)),s=0;n[s];s++)n[s].apply(this,r);return!i},e.once=function(r,s){if("object"==typeof r&&a(s)){var t,e=r;for(t in e)this.once(t,e[t]);return this}if("string"==typeof r&&"function"==typeof s){var o=this;this.on(r,function t(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];s.apply(o,n),o.off(r,t)})}return this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&a(e)){var n,i=t;for(n in i)this.on(n,i[n]);return this}if("string"==typeof t&&"function"==typeof e){var r=this._eventHandler[t];a(r)&&(this._eventHandler[t]=[],r=this._eventHandler[t]),r.push(e)}return this},e.off=function(t,e){if(a(t))return this._eventHandler={},this;if(a(e)){if("string"==typeof t)return this._eventHandler[t]=void 0,this;var n,i=t;for(n in i)this.off(n,i[n]);return this}var r,s,o=this._eventHandler[t];if(o)for(r=0;void 0!==(s=o[r]);r++)if(s===e){o=o.splice(r,1);break}return this},t}();return t.VERSION="2.1.2",t}();function h(t,e,n,i){t.addEventListener(e,n,i)}function n(t,e,n){t.removeEventListener(e,n)}var u=function(){return(u=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function f(t,e,n,i){var r=y(t),s=y(e),o=y(i);return p(b(i[0],E(r,o)),b(i[0],E(s,o)),n[0])}function d(t){return t.touches?m(t.touches):[r(t)]}function p(t,e,n){var i=t.clientX,r=t.clientY;return{clientX:i,clientY:r,deltaX:i-e.clientX,deltaY:r-e.clientY,distX:i-n.clientX,distY:r-n.clientY}}function v(t){return Math.sqrt(Math.pow(t[0].clientX-t[1].clientX,2)+Math.pow(t[0].clientY-t[1].clientY,2))}function g(t,n,i){return t.map(function(t,e){return p(t,n[e],i[e])})}function m(t){for(var e=Math.min(t.length,2),n=[],i=0;i<e;++i)n.push(r(t[i]));return n}function r(t){return{clientX:t.clientX,clientY:t.clientY}}function y(t){return{clientX:(t[0].clientX+t[1].clientX)/2,clientY:(t[0].clientY+t[1].clientY)/2}}function b(t,e){return{clientX:t.clientX+e.clientX,clientY:t.clientY+e.clientY}}function E(t,e){return{clientX:t.clientX-e.clientX,clientY:t.clientY-e.clientY}}var C=function(){function t(t,e){var o=this;void 0===e&&(e={}),this.el=t,this.options={},this.flag=!1,this.pinchFlag=!1,this.datas={},this.isDrag=!1,this.isPinch=!1,this.isMouse=!1,this.isTouch=!1,this.prevClients=[],this.startClients=[],this.movement=0,this.startPinchClients=[],this.startDistance=0,this.customDist=[0,0],this.onDragStart=function(t){if(o.flag||!1!==t.cancelable){if((e=t).touches&&2<=e.touches.length){if(!o.flag&&t.touches.length!==t.changedTouches.length)return;o.pinchFlag||o.onPinchStart(t)}var e;if(!o.flag){var n=o.startClients[0]?o.startClients:d(t);o.customDist=[0,0],o.flag=!0,o.isDrag=!1,o.startClients=n,o.prevClients=n,o.datas={};var i=p(n[o.movement=0],o.prevClients[0],o.startClients[0]),r=o.options,s=r.dragstart;(r.preventRightClick&&3===t.which||!1===(s&&s(u({datas:o.datas,inputEvent:t},i))))&&(o.startClients=[],o.prevClients=[],o.flag=!1),o.flag&&t.preventDefault()}}},this.onDrag=function(t,e){if(o.flag){var n=d(t);o.pinchFlag&&o.onPinch(t,n);var i=o.move([0,0],t,n);if(i&&(i.deltaX||i.deltaY)){var r=o.options.drag;r&&r(u({},i,{isScroll:!!e,inputEvent:t}))}}},this.onDragEnd=function(t){if(o.flag){o.pinchFlag&&o.onPinchEnd(t),o.flag=!1;var e=o.options.dragend,n=o.prevClients,i=o.startClients,r=o.pinchFlag?f(n,n,i,o.startPinchClients):p(n[0],n[0],i[0]);o.startClients=[],o.prevClients=[],e&&e(u({datas:o.datas,isDrag:o.isDrag,inputEvent:t},r))}},this.options=u({container:t,preventRightClick:!0,pinchThreshold:0,events:["touch","mouse"]},e);var n=this.options,i=n.container,r=n.events;if(this.isTouch=-1<r.indexOf("touch"),this.isMouse=-1<r.indexOf("mouse"),this.customDist=[0,0],this.isMouse&&(h(t,"mousedown",this.onDragStart),h(i,"mousemove",this.onDrag),h(i,"mouseup",this.onDragEnd)),this.isTouch){var s={passive:!1};h(t,"touchstart",this.onDragStart,s),h(i,"touchmove",this.onDrag,s),h(i,"touchend",this.onDragEnd,s)}}var e=t.prototype;return e.isDragging=function(){return this.isDrag},e.isPinching=function(){return this.isPinch},e.scrollBy=function(e,n,t,i){void 0===i&&(i=!0),this.flag&&(this.startClients.forEach(function(t){t.clientX-=e,t.clientY-=n}),this.prevClients.forEach(function(t){t.clientX-=e,t.clientY-=n}),i&&this.onDrag(t,!0))},e.move=function(t,e,n){var i=t[0],r=t[1];void 0===n&&(n=this.prevClients);var s=this.customDist,o=this.prevClients,a=this.startClients,c=this.pinchFlag?f(n,o,a,this.startPinchClients):p(n[0],o[0],a[0]);s[0]+=i,s[1]+=r,c.deltaX+=i,c.deltaY+=r;var l=c.deltaX,h=c.deltaY;return c.distX+=s[0],c.distY+=s[1],this.movement+=Math.sqrt(l*l+h*h),this.prevClients=n,this.isDrag=!0,u({datas:this.datas},c,{isScroll:!1,inputEvent:e})},e.onPinchStart=function(t){var e,n,i=this.options,r=i.pinchstart,s=i.pinchThreshold;if(!(this.isDrag&&this.movement>s)){var o=m(t.changedTouches);if(this.pinchFlag=!0,(e=this.startClients).push.apply(e,o),(n=this.prevClients).push.apply(n,o),this.startDistance=v(this.prevClients),this.startPinchClients=this.prevClients.slice(),r){var a=this.prevClients,c=y(a),l=p(c,c,c);r(u({datas:this.datas,touches:g(a,a,a)},l,{inputEvent:t}))}}},e.onPinch=function(t,e){if(this.flag&&this.pinchFlag){this.isPinch=!0;var n=this.options.pinch;if(n){var i=this.prevClients,r=this.startClients,s=p(y(e),y(i),y(r)),o=v(e);n(u({datas:this.datas,touches:g(e,i,r),scale:o/this.startDistance,distance:o},s,{inputEvent:t}))}}},e.onPinchEnd=function(t){if(this.flag&&this.pinchFlag){var e=this.isPinch;this.isPinch=!1,this.pinchFlag=!1;var n=this.options.pinchend;if(n){var i=this.prevClients,r=this.startClients,s=p(y(i),y(i),y(r));n(u({datas:this.datas,isPinch:e,touches:g(i,i,r)},s,{inputEvent:t})),this.isPinch=!1,this.pinchFlag=!1}}},e.unset=function(){var t=this.el,e=this.options.container;this.isMouse&&(n(t,"mousedown",this.onDragStart),n(e,"mousemove",this.onDrag),n(e,"mouseup",this.onDragEnd)),this.isTouch&&(n(t,"touchstart",this.onDragStart),n(e,"touchmove",this.onDrag),n(e,"touchend",this.onDragEnd))},t}();var e=function(t){for(var e=5381,n=t.length;n;)e=33*e^t.charCodeAt(--n);return e>>>0};function s(i,t,e){var n=document.createElement("style");return n.setAttribute("type","text/css"),n.innerHTML=t.replace(/([^}{]*){/gm,function(t,e){return((n=e.match(/("[^"]*"|'[^']*'|[^,\s()]*\((?:[^()]*|\([^()]*\))*\)[^,\s()]*|[^,])+/g))?n.map(function(t){return t.trim()}):[]).map(function(t){return-1<t.indexOf(":global")?t.replace(/\:global/g,""):-1<t.indexOf(":host")?""+t.replace(/\:host/g,"."+i):"."+i+" "+t}).join(", ")+"{";var n}),(e||document.head||document.body).appendChild(n),n}var O=function(){function t(){this.keys=[],this.values=[]}var e=t.prototype;return e.get=function(t){return this.values[this.keys.indexOf(t)]},e.set=function(t,e){var n=this.keys,i=this.values,r=n.indexOf(t),s=-1===r?n.length:r;n[s]=t,i[s]=e},t}(),D=function(){function t(){this.object={}}var e=t.prototype;return e.get=function(t){return this.object[t]},e.set=function(t,e){this.object[t]=e},t}(),T="function"==typeof Map,o=function(){function t(){}var e=t.prototype;return e.connect=function(t,e){this.prev=t,this.next=e,t&&(t.next=this),e&&(e.prev=this)},e.disconnect=function(){var t=this.prev,e=this.next;t&&(t.next=e),e&&(e.prev=t)},e.getIndex=function(){for(var t=this,e=-1;t;)t=t.prev,++e;return e},t}();var Y=function(){function t(t,e,n,i,r,s,o,a){this.prevList=t,this.list=e,this.added=n,this.removed=i,this.changed=r,this.maintained=s,this.changedBeforeAdded=o,this.fixed=a}var e=t.prototype;return Object.defineProperty(e,"ordered",{get:function(){return this.cacheOrdered||this.caculateOrdered(),this.cacheOrdered},enumerable:!0,configurable:!0}),Object.defineProperty(e,"pureChanged",{get:function(){return this.cachePureChanged||this.caculateOrdered(),this.cachePureChanged},enumerable:!0,configurable:!0}),e.caculateOrdered=function(){var t,n,a,c,e=(t=this.changedBeforeAdded,n=this.fixed,a=[],c=[],t.forEach(function(t){var e=t[0],n=t[1],i=new o;a[e]=i,c[n]=i}),a.forEach(function(t,e){t.connect(a[e-1])}),t.filter(function(t,e){return!n[e]}).map(function(t,e){var n=t[0],i=t[1];if(n===i)return[0,0];var r=a[n],s=c[i-1],o=r.getIndex();return r.disconnect(),s?r.connect(s,s.next):r.connect(void 0,a[0]),[o,r.getIndex()]})),l=this.changed,h=[];this.cacheOrdered=e.filter(function(t,e){var n=t[0],i=t[1],r=l[e],s=r[0],o=r[1];if(n!==i)return h.push([s,o]),!0}),this.cachePureChanged=h},t}();function i(t,e,n){var i=T?Map:n?D:O,r=n||function(t){return t},s=[],o=[],a=[],c=t.map(r),l=e.map(r),h=new i,u=new i,f=[],d=[],p={},v=[],g=0,m=0;return c.forEach(function(t,e){h.set(t,e)}),l.forEach(function(t,e){u.set(t,e)}),c.forEach(function(t,e){var n=u.get(t);void 0===n?(++m,o.push(e)):p[n]=m}),l.forEach(function(t,e){var n=h.get(t);void 0===n?(s.push(e),++g):(a.push([n,e]),m=p[e]||0,f.push([n-m,e-g]),d.push(e===n),n!==e&&v.push([n,e]))}),o.reverse(),new Y(t,e,s,o,v,a,f,d)}var P=function(t,e){return(P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var X,x="function"==typeof Map?void 0:(X=0,function(t){return t.__DIFF_KEY__||(t.__DIFF_KEY__=++X)}),_=function(e){function t(){this.constructor=n}var n,i;function r(t){return void 0===t&&(t=[]),e.call(this,t,x)||this}return P(n=r,i=e),n.prototype=null===i?Object.create(i):(t.prototype=i.prototype,new t),r}(function(){function t(t,e){void 0===t&&(t=[]),this.findKeyCallback=e,this.list=[].slice.call(t)}return t.prototype.update=function(t){var e=[].slice.call(t),n=i(this.list,e,this.findKeyCallback);return this.list=e,n},t}());function j(t,e){return i(t,e,x)}function S(t,e,n){var i=t.tag,r=t.children,s=t.attributes,o=t.className,a=t.style,c=e||document.createElement(i);for(var l in s)c.setAttribute(l,s[l]);var h=c.children;if(r.forEach(function(t,e){S(t,h[e],c)}),o&&o.split(" ").forEach(function(t){var e,n,i,r;r=t,((i=c).classList?i.classList.contains(r):i.className.match(new RegExp("(\\s|^)"+r+"(\\s|$)")))||(n=t,(e=c).classList?e.classList.add(n):e.className+=" "+n)}),a){var u=c.style;for(var l in a)u[l]=a[l]}return!e&&n&&n.appendChild(c),c}function w(t,e){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var r=e||{},s=r.className,o=r.style;return{tag:t,className:void 0===s?"":s,style:void 0===o?{}:o,attributes:function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]])}return n}(r,["className","style"]),children:n}}var M,R,F,k,N=["selectableTargets","continueSelect","hitRate"],L=(F="rCS"+e(M="\n:host {\n position: absolute;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n").toString(36),k=0,{className:F,inject:function(t){var e,n=function(t){if(t.getRootNode){var e=t.getRootNode();if(11===e.nodeType)return e}}(t),i=0===k;return(n||i)&&(e=s(F,M)),i&&(R=e),n||++k,{destroy:function(){n?(t.removeChild(e),e=null):(0<k&&--k,0===k&&R&&(R.parentNode.removeChild(R),R=null))}}}});return function(e){function t(){this.constructor=n}var n,i;function r(t){void 0===t&&(t={});var v=e.call(this)||this;return v.selectedTargets=[],v.differ=new _,v.onDragStart=function(t){var e=t.datas,n=t.clientX,i=t.clientY,r=t.inputEvent,s=v.options,o=s.continueSelect,a=s.selectOutside,c=v.getSelectableTargets(),l=c.map(function(t){var e=t.getBoundingClientRect(),n=e.left,i=e.top;return{left:n,top:i,right:n+e.width,bottom:i+e.height}});e.selectableTargets=c,e.selectableRects=l,e.startSelectedTargets=v.selectedTargets;var h=document.elementFromPoint(n,i),u=v.hitTest({left:n,top:i,right:n,bottom:i},n,i,c,l).filter(function(t){return t===h||t.contains(h)}),f=0<u.length;return o?u=v.getSelectedTargets(u):v.selectedTargets=[],v.select(u,r,!0),e.startX=n,e.startY=i,e.selectedTargets=u,v.target.style.cssText+="left:"+n+"px;top:"+i+"px",!a||!f||(v.onDragEnd(t),!1)},v.onDrag=function(t){var e=t.distX,n=t.distY,i=t.datas,r=t.inputEvent,s=i.startX,o=i.startY,a=Math.min(0,e),c=Math.min(0,n),l=Math.abs(e),h=Math.abs(n);v.target.style.cssText+="display: block;transform: translate("+a+"px, "+c+"px);width:"+l+"px;height:"+h+"px;";var u=s+a,f=o+c,d=v.hitTest({left:u,top:f,right:u+l,bottom:f+h},i.startX,i.startY,i.selectableTargets,i.selectableRects),p=v.getSelectedTargets(d);v.select(p,r),i.selectedTargets=p},v.onDragEnd=function(t){var e=t.datas,n=t.inputEvent;v.target.style.cssText+="display: none;",v.selecteEnd(e.startSelectedTargets,e.selectedTargets,n),v.selectedTargets=e.selectedTargets},v.target=t.target,v.container=t.container,v.options=l({target:null,container:null,dragContainer:null,selectableTargets:[],selectByClick:!0,selectOutside:!1,hitRate:100,continueSelect:!1},t),v.initElement(),v}c(n=r,i=e),n.prototype=null===i?Object.create(i):(t.prototype=i.prototype,new t);var s,o,a=r.prototype;return a.destroy=function(){this.dragger.unset(),this.injectResult.destroy(),this.dragger=null,this.injectResult=null,this.target=null,this.container=null,this.options=null},a.click=function(t){var e=function(t){if("touches"in t){var e=t.touches[0];return{clientX:e.clientX,clientY:e.clientY}}return{clientX:t.clientX,clientY:t.clientY}}(t),n={datas:{},clientX:e.clientX,clientY:e.clientY,inputEvent:t};this.onDragStart(n)&&this.onDragEnd(n)},a.initElement=function(){this.target=S(w("div",{className:"selecto-selection "+L.className}),this.target,this.container);var t=this.target;this.dragger=new C(this.options.dragContainer||this.target.parentElement,{container:window,dragstart:this.onDragStart,drag:this.onDrag,dragend:this.onDragEnd}),this.injectResult=L.inject(t)},a.hitTest=function(t,d,p,v,e){var n=this.options,g=n.hitRate,m=n.selectByClick,y=t.left,b=t.top,E=t.right,C=t.bottom,O=[];return e.forEach(function(t,e){var n=t.left,i=t.top,r=t.right,s=t.bottom,o=n<=d&&d<=r&&i<=p&&p<=s,a=(r-n)*(s-i),c=Math.max(n,y),l=Math.min(r,E),h=Math.max(i,b),u=Math.min(s,C);if(m&&o)O.push(v[e]);else if(!(l<c||u<h)){var f=Math.round((l-c)*(u-h)/a*100);g<=f&&O.push(v[e])}}),O},a.getSelectableTargets=function(){var n=[];return this.options.selectableTargets.forEach(function(t){var e;(e=t)&&"object"==typeof e?n.push(t):[].slice.call(document.querySelectorAll(t)).forEach(function(t){n.push(t)})}),n},a.getSelectedTargets=function(t){var e=j(this.selectedTargets,t),n=e.list,i=e.prevList,r=e.added,s=e.removed;return r.map(function(t){return n[t]}).concat(s.map(function(t){return i[t]}))},a.select=function(t,e,n){var i=this.differ.update(t),r=i.added,s=i.removed,o=i.prevList,a=i.list;n&&this.trigger("selectStart",{selected:t,added:r.map(function(t){return a[t]}),removed:s.map(function(t){return o[t]}),inputEvent:e}),(r.length||s.length)&&this.trigger("select",{selected:t,added:r.map(function(t){return a[t]}),removed:s.map(function(t){return o[t]}),inputEvent:e})},a.selecteEnd=function(t,e,n){var i=j(t,e),r=i.added,s=i.removed,o=i.prevList,a=i.list,c=j(this.selectedTargets,e),l=c.added,h=c.removed,u=c.prevList,f=c.list;this.trigger("selectEnd",{selected:e,added:r.map(function(t){return a[t]}),removed:s.map(function(t){return o[t]}),afterAdded:l.map(function(t){return f[t]}),afterRemoved:h.map(function(t){return u[t]}),inputEvent:n})},r=function(t,e,n,i){var r,s=arguments.length,o=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;0<=a;a--)(r=t[a])&&(o=(s<3?r(o):3<s?r(e,n,o):r(e,n))||o);return 3<s&&o&&Object.defineProperty(e,n,o),o}([(s=N,o=function(t,e){Object.defineProperty(t,e,{get:function(){return this.options[e]},set:function(t){this.options[e]=t},enumerable:!0,configurable:!0})},function(t){var e=t.prototype;s.forEach(function(t){o(e,t)})})],r)}(t)}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Selecto=e()}(this,function(){"use strict";var c=function(t,e){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var l=function(){return(l=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function a(t){return void 0===t}var t=function(){var t=function(){function t(){this._eventHandler={},this.options={}}var e=t.prototype;return e.trigger=function(t,e){void 0===e&&(e={});var n=this._eventHandler[t]||[];if(!(0<n.length))return!0;n=n.concat(),e.eventType=t;var i=!1,r=[e],s=0;e.stop=function(){i=!0},e.currentTarget=this;for(var o=arguments.length,a=new Array(2<o?o-2:0),c=2;c<o;c++)a[c-2]=arguments[c];for(1<=a.length&&(r=r.concat(a)),s=0;n[s];s++)n[s].apply(this,r);return!i},e.once=function(r,s){if("object"==typeof r&&a(s)){var t,e=r;for(t in e)this.once(t,e[t]);return this}if("string"==typeof r&&"function"==typeof s){var o=this;this.on(r,function t(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];s.apply(o,n),o.off(r,t)})}return this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&a(e)){var n,i=t;for(n in i)this.on(n,i[n]);return this}if("string"==typeof t&&"function"==typeof e){var r=this._eventHandler[t];a(r)&&(this._eventHandler[t]=[],r=this._eventHandler[t]),r.push(e)}return this},e.off=function(t,e){if(a(t))return this._eventHandler={},this;if(a(e)){if("string"==typeof t)return this._eventHandler[t]=void 0,this;var n,i=t;for(n in i)this.off(n,i[n]);return this}var r,s,o=this._eventHandler[t];if(o)for(r=0;void 0!==(s=o[r]);r++)if(s===e){o=o.splice(r,1);break}return this},t}();return t.VERSION="2.1.2",t}();function h(t,e,n,i){t.addEventListener(e,n,i)}function n(t,e,n){t.removeEventListener(e,n)}var u=function(){return(u=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function f(t,e,n,i){var r=y(t),s=y(e),o=y(i);return p(b(i[0],E(r,o)),b(i[0],E(s,o)),n[0])}function d(t){return t.touches?m(t.touches):[r(t)]}function p(t,e,n){var i=t.clientX,r=t.clientY;return{clientX:i,clientY:r,deltaX:i-e.clientX,deltaY:r-e.clientY,distX:i-n.clientX,distY:r-n.clientY}}function v(t){return Math.sqrt(Math.pow(t[0].clientX-t[1].clientX,2)+Math.pow(t[0].clientY-t[1].clientY,2))}function g(t,n,i){return t.map(function(t,e){return p(t,n[e],i[e])})}function m(t){for(var e=Math.min(t.length,2),n=[],i=0;i<e;++i)n.push(r(t[i]));return n}function r(t){return{clientX:t.clientX,clientY:t.clientY}}function y(t){return{clientX:(t[0].clientX+t[1].clientX)/2,clientY:(t[0].clientY+t[1].clientY)/2}}function b(t,e){return{clientX:t.clientX+e.clientX,clientY:t.clientY+e.clientY}}function E(t,e){return{clientX:t.clientX-e.clientX,clientY:t.clientY-e.clientY}}var C=function(){function t(t,e){var o=this;void 0===e&&(e={}),this.el=t,this.options={},this.flag=!1,this.pinchFlag=!1,this.datas={},this.isDrag=!1,this.isPinch=!1,this.isMouse=!1,this.isTouch=!1,this.prevClients=[],this.startClients=[],this.movement=0,this.startPinchClients=[],this.startDistance=0,this.customDist=[0,0],this.onDragStart=function(t){if(o.flag||!1!==t.cancelable){if((e=t).touches&&2<=e.touches.length){if(!o.flag&&t.touches.length!==t.changedTouches.length)return;o.pinchFlag||o.onPinchStart(t)}var e;if(!o.flag){var n=o.startClients[0]?o.startClients:d(t);o.customDist=[0,0],o.flag=!0,o.isDrag=!1,o.startClients=n,o.prevClients=n,o.datas={};var i=p(n[o.movement=0],o.prevClients[0],o.startClients[0]),r=o.options,s=r.dragstart;(r.preventRightClick&&3===t.which||!1===(s&&s(u({datas:o.datas,inputEvent:t},i))))&&(o.startClients=[],o.prevClients=[],o.flag=!1),o.flag&&t.preventDefault()}}},this.onDrag=function(t,e){if(o.flag){var n=d(t);o.pinchFlag&&o.onPinch(t,n);var i=o.move([0,0],t,n);if(i&&(i.deltaX||i.deltaY)){var r=o.options.drag;r&&r(u({},i,{isScroll:!!e,inputEvent:t}))}}},this.onDragEnd=function(t){if(o.flag){o.pinchFlag&&o.onPinchEnd(t),o.flag=!1;var e=o.options.dragend,n=o.prevClients,i=o.startClients,r=o.pinchFlag?f(n,n,i,o.startPinchClients):p(n[0],n[0],i[0]);o.startClients=[],o.prevClients=[],e&&e(u({datas:o.datas,isDrag:o.isDrag,inputEvent:t},r))}},this.options=u({container:t,preventRightClick:!0,pinchThreshold:0,events:["touch","mouse"]},e);var n=this.options,i=n.container,r=n.events;if(this.isTouch=-1<r.indexOf("touch"),this.isMouse=-1<r.indexOf("mouse"),this.customDist=[0,0],this.isMouse&&(h(t,"mousedown",this.onDragStart),h(i,"mousemove",this.onDrag),h(i,"mouseup",this.onDragEnd)),this.isTouch){var s={passive:!1};h(t,"touchstart",this.onDragStart,s),h(i,"touchmove",this.onDrag,s),h(i,"touchend",this.onDragEnd,s)}}var e=t.prototype;return e.isDragging=function(){return this.isDrag},e.isPinching=function(){return this.isPinch},e.scrollBy=function(e,n,t,i){void 0===i&&(i=!0),this.flag&&(this.startClients.forEach(function(t){t.clientX-=e,t.clientY-=n}),this.prevClients.forEach(function(t){t.clientX-=e,t.clientY-=n}),i&&this.onDrag(t,!0))},e.move=function(t,e,n){var i=t[0],r=t[1];void 0===n&&(n=this.prevClients);var s=this.customDist,o=this.prevClients,a=this.startClients,c=this.pinchFlag?f(n,o,a,this.startPinchClients):p(n[0],o[0],a[0]);s[0]+=i,s[1]+=r,c.deltaX+=i,c.deltaY+=r;var l=c.deltaX,h=c.deltaY;return c.distX+=s[0],c.distY+=s[1],this.movement+=Math.sqrt(l*l+h*h),this.prevClients=n,this.isDrag=!0,u({datas:this.datas},c,{isScroll:!1,inputEvent:e})},e.onPinchStart=function(t){var e,n,i=this.options,r=i.pinchstart,s=i.pinchThreshold;if(!(this.isDrag&&this.movement>s)){var o=m(t.changedTouches);if(this.pinchFlag=!0,(e=this.startClients).push.apply(e,o),(n=this.prevClients).push.apply(n,o),this.startDistance=v(this.prevClients),this.startPinchClients=this.prevClients.slice(),r){var a=this.prevClients,c=y(a),l=p(c,c,c);r(u({datas:this.datas,touches:g(a,a,a)},l,{inputEvent:t}))}}},e.onPinch=function(t,e){if(this.flag&&this.pinchFlag){this.isPinch=!0;var n=this.options.pinch;if(n){var i=this.prevClients,r=this.startClients,s=p(y(e),y(i),y(r)),o=v(e);n(u({datas:this.datas,touches:g(e,i,r),scale:o/this.startDistance,distance:o},s,{inputEvent:t}))}}},e.onPinchEnd=function(t){if(this.flag&&this.pinchFlag){var e=this.isPinch;this.isPinch=!1,this.pinchFlag=!1;var n=this.options.pinchend;if(n){var i=this.prevClients,r=this.startClients,s=p(y(i),y(i),y(r));n(u({datas:this.datas,isPinch:e,touches:g(i,i,r)},s,{inputEvent:t})),this.isPinch=!1,this.pinchFlag=!1}}},e.unset=function(){var t=this.el,e=this.options.container;this.isMouse&&(n(t,"mousedown",this.onDragStart),n(e,"mousemove",this.onDrag),n(e,"mouseup",this.onDragEnd)),this.isTouch&&(n(t,"touchstart",this.onDragStart),n(e,"touchmove",this.onDrag),n(e,"touchend",this.onDragEnd))},t}();var e=function(t){for(var e=5381,n=t.length;n;)e=33*e^t.charCodeAt(--n);return e>>>0};function s(i,t,e){var n=document.createElement("style");return n.setAttribute("type","text/css"),n.innerHTML=t.replace(/([^}{]*){/gm,function(t,e){return((n=e.match(/("[^"]*"|'[^']*'|[^,\s()]*\((?:[^()]*|\([^()]*\))*\)[^,\s()]*|[^,])+/g))?n.map(function(t){return t.trim()}):[]).map(function(t){return-1<t.indexOf(":global")?t.replace(/\:global/g,""):-1<t.indexOf(":host")?""+t.replace(/\:host/g,"."+i):"."+i+" "+t}).join(", ")+"{";var n}),(e||document.head||document.body).appendChild(n),n}var O=function(){function t(){this.keys=[],this.values=[]}var e=t.prototype;return e.get=function(t){return this.values[this.keys.indexOf(t)]},e.set=function(t,e){var n=this.keys,i=this.values,r=n.indexOf(t),s=-1===r?n.length:r;n[s]=t,i[s]=e},t}(),D=function(){function t(){this.object={}}var e=t.prototype;return e.get=function(t){return this.object[t]},e.set=function(t,e){this.object[t]=e},t}(),T="function"==typeof Map,o=function(){function t(){}var e=t.prototype;return e.connect=function(t,e){this.prev=t,this.next=e,t&&(t.next=this),e&&(e.prev=this)},e.disconnect=function(){var t=this.prev,e=this.next;t&&(t.next=e),e&&(e.prev=t)},e.getIndex=function(){for(var t=this,e=-1;t;)t=t.prev,++e;return e},t}();var Y=function(){function t(t,e,n,i,r,s,o,a){this.prevList=t,this.list=e,this.added=n,this.removed=i,this.changed=r,this.maintained=s,this.changedBeforeAdded=o,this.fixed=a}var e=t.prototype;return Object.defineProperty(e,"ordered",{get:function(){return this.cacheOrdered||this.caculateOrdered(),this.cacheOrdered},enumerable:!0,configurable:!0}),Object.defineProperty(e,"pureChanged",{get:function(){return this.cachePureChanged||this.caculateOrdered(),this.cachePureChanged},enumerable:!0,configurable:!0}),e.caculateOrdered=function(){var t,n,a,c,e=(t=this.changedBeforeAdded,n=this.fixed,a=[],c=[],t.forEach(function(t){var e=t[0],n=t[1],i=new o;a[e]=i,c[n]=i}),a.forEach(function(t,e){t.connect(a[e-1])}),t.filter(function(t,e){return!n[e]}).map(function(t,e){var n=t[0],i=t[1];if(n===i)return[0,0];var r=a[n],s=c[i-1],o=r.getIndex();return r.disconnect(),s?r.connect(s,s.next):r.connect(void 0,a[0]),[o,r.getIndex()]})),l=this.changed,h=[];this.cacheOrdered=e.filter(function(t,e){var n=t[0],i=t[1],r=l[e],s=r[0],o=r[1];if(n!==i)return h.push([s,o]),!0}),this.cachePureChanged=h},t}();function i(t,e,n){var i=T?Map:n?D:O,r=n||function(t){return t},s=[],o=[],a=[],c=t.map(r),l=e.map(r),h=new i,u=new i,f=[],d=[],p={},v=[],g=0,m=0;return c.forEach(function(t,e){h.set(t,e)}),l.forEach(function(t,e){u.set(t,e)}),c.forEach(function(t,e){var n=u.get(t);void 0===n?(++m,o.push(e)):p[n]=m}),l.forEach(function(t,e){var n=h.get(t);void 0===n?(s.push(e),++g):(a.push([n,e]),m=p[e]||0,f.push([n-m,e-g]),d.push(e===n),n!==e&&v.push([n,e]))}),o.reverse(),new Y(t,e,s,o,v,a,f,d)}var P=function(t,e){return(P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var X,x="function"==typeof Map?void 0:(X=0,function(t){return t.__DIFF_KEY__||(t.__DIFF_KEY__=++X)}),_=function(e){function t(){this.constructor=n}var n,i;function r(t){return void 0===t&&(t=[]),e.call(this,t,x)||this}return P(n=r,i=e),n.prototype=null===i?Object.create(i):(t.prototype=i.prototype,new t),r}(function(){function t(t,e){void 0===t&&(t=[]),this.findKeyCallback=e,this.list=[].slice.call(t)}return t.prototype.update=function(t){var e=[].slice.call(t),n=i(this.list,e,this.findKeyCallback);return this.list=e,n},t}());function j(t,e){return i(t,e,x)}function S(t,e,n){var i=t.tag,r=t.children,s=t.attributes,o=t.className,a=t.style,c=e||document.createElement(i);for(var l in s)c.setAttribute(l,s[l]);var h=c.children;if(r.forEach(function(t,e){S(t,h[e],c)}),o&&o.split(" ").forEach(function(t){var e,n,i,r;r=t,((i=c).classList?i.classList.contains(r):i.className.match(new RegExp("(\\s|^)"+r+"(\\s|$)")))||(n=t,(e=c).classList?e.classList.add(n):e.className+=" "+n)}),a){var u=c.style;for(var l in a)u[l]=a[l]}return!e&&n&&n.appendChild(c),c}function w(t,e){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var r=e||{},s=r.className,o=r.style;return{tag:t,className:void 0===s?"":s,style:void 0===o?{}:o,attributes:function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]])}return n}(r,["className","style"]),children:n}}var M,R,F,k,N=["selectableTargets","continueSelect","hitRate"],L=(F="rCS"+e(M="\n:host {\n position: absolute;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n").toString(36),k=0,{className:F,inject:function(t){var e,n=function(t){if(t.getRootNode){var e=t.getRootNode();if(11===e.nodeType)return e}}(t),i=0===k;return(n||i)&&(e=s(F,M)),i&&(R=e),n||++k,{destroy:function(){n?(t.removeChild(e),e=null):(0<k&&--k,0===k&&R&&(R.parentNode.removeChild(R),R=null))}}}});return function(e){function t(){this.constructor=n}var n,i;function r(t){void 0===t&&(t={});var v=e.call(this)||this;return v.selectedTargets=[],v.differ=new _,v.onDragStart=function(t){var e=t.datas,n=t.clientX,i=t.clientY,r=t.inputEvent,s=v.options,o=s.continueSelect,a=s.selectOutside,c=v.getSelectableTargets(),l=c.map(function(t){var e=t.getBoundingClientRect(),n=e.left,i=e.top;return{left:n,top:i,right:n+e.width,bottom:i+e.height}});e.selectableTargets=c,e.selectableRects=l,e.startSelectedTargets=v.selectedTargets;var h=document.elementFromPoint(n,i),u=v.hitTest({left:n,top:i,right:n,bottom:i},n,i,c,l).filter(function(t){return t===h||t.contains(h)}),f=0<u.length;o?u=v.getSelectedTargets(u):v.selectedTargets=[];var d=r.type;return!(("mousedown"===d||"touchstart"===d)&&!v.trigger("dragStart",t))&&(v.select(u,r,!0),e.startX=n,e.startY=i,e.selectedTargets=u,v.target.style.cssText+="left:"+n+"px;top:"+i+"px",!a||!f||(v.onDragEnd(t),!1))},v.onDrag=function(t){var e=t.distX,n=t.distY,i=t.datas,r=t.inputEvent,s=i.startX,o=i.startY,a=Math.min(0,e),c=Math.min(0,n),l=Math.abs(e),h=Math.abs(n);v.target.style.cssText+="display: block;transform: translate("+a+"px, "+c+"px);width:"+l+"px;height:"+h+"px;";var u=s+a,f=o+c,d=v.hitTest({left:u,top:f,right:u+l,bottom:f+h},i.startX,i.startY,i.selectableTargets,i.selectableRects),p=v.getSelectedTargets(d);v.select(p,r),i.selectedTargets=p},v.onDragEnd=function(t){var e=t.datas,n=t.inputEvent;v.target.style.cssText+="display: none;",v.selecteEnd(e.startSelectedTargets,e.selectedTargets,n),v.selectedTargets=e.selectedTargets},v.target=t.target,v.container=t.container,v.options=l({target:null,container:null,dragContainer:null,selectableTargets:[],selectByClick:!0,selectOutside:!1,hitRate:100,continueSelect:!1},t),v.initElement(),v}c(n=r,i=e),n.prototype=null===i?Object.create(i):(t.prototype=i.prototype,new t);var s,o,a=r.prototype;return a.destroy=function(){this.dragger.unset(),this.injectResult.destroy(),this.dragger=null,this.injectResult=null,this.target=null,this.container=null,this.options=null},a.click=function(t){var e=function(t){if("touches"in t){var e=t.touches[0];return{clientX:e.clientX,clientY:e.clientY}}return{clientX:t.clientX,clientY:t.clientY}}(t),n={datas:{},clientX:e.clientX,clientY:e.clientY,inputEvent:t};this.onDragStart(n)&&this.onDragEnd(n)},a.initElement=function(){this.target=S(w("div",{className:"selecto-selection "+L.className}),this.target,this.container);var t=this.target;this.dragger=new C(this.options.dragContainer||this.target.parentElement,{container:window,dragstart:this.onDragStart,drag:this.onDrag,dragend:this.onDragEnd}),this.injectResult=L.inject(t)},a.hitTest=function(t,d,p,v,e){var n=this.options,g=n.hitRate,m=n.selectByClick,y=t.left,b=t.top,E=t.right,C=t.bottom,O=[];return e.forEach(function(t,e){var n=t.left,i=t.top,r=t.right,s=t.bottom,o=n<=d&&d<=r&&i<=p&&p<=s,a=(r-n)*(s-i),c=Math.max(n,y),l=Math.min(r,E),h=Math.max(i,b),u=Math.min(s,C);if(m&&o)O.push(v[e]);else if(!(l<c||u<h)){var f=Math.round((l-c)*(u-h)/a*100);g<=f&&O.push(v[e])}}),O},a.getSelectableTargets=function(){var n=[];return this.options.selectableTargets.forEach(function(t){var e;(e=t)&&"object"==typeof e?n.push(t):[].slice.call(document.querySelectorAll(t)).forEach(function(t){n.push(t)})}),n},a.getSelectedTargets=function(t){var e=j(this.selectedTargets,t),n=e.list,i=e.prevList,r=e.added,s=e.removed;return r.map(function(t){return n[t]}).concat(s.map(function(t){return i[t]}))},a.select=function(t,e,n){var i=this.differ.update(t),r=i.added,s=i.removed,o=i.prevList,a=i.list;n&&this.trigger("selectStart",{selected:t,added:r.map(function(t){return a[t]}),removed:s.map(function(t){return o[t]}),inputEvent:e}),(r.length||s.length)&&this.trigger("select",{selected:t,added:r.map(function(t){return a[t]}),removed:s.map(function(t){return o[t]}),inputEvent:e})},a.selecteEnd=function(t,e,n){var i=j(t,e),r=i.added,s=i.removed,o=i.prevList,a=i.list,c=j(this.selectedTargets,e),l=c.added,h=c.removed,u=c.prevList,f=c.list;this.trigger("selectEnd",{selected:e,added:r.map(function(t){return a[t]}),removed:s.map(function(t){return o[t]}),afterAdded:l.map(function(t){return f[t]}),afterRemoved:h.map(function(t){return u[t]}),inputEvent:n})},r=function(t,e,n,i){var r,s=arguments.length,o=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;0<=a;a--)(r=t[a])&&(o=(s<3?r(o):3<s?r(e,n,o):r(e,n))||o);return 3<s&&o&&Object.defineProperty(e,n,o),o}([(s=N,o=function(t,e){Object.defineProperty(t,e,{get:function(){return this.options[e]},set:function(t){this.options[e]=t},enumerable:!0,configurable:!0})},function(t){var e=t.prototype;s.forEach(function(t){o(e,t)})})],r)}(t)}); | ||
//# sourceMappingURL=selecto.pkgd.min.js.map |
{ | ||
"name": "selecto", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/selecto.cjs.js", |
@@ -8,2 +8,3 @@ export const PROPERTIES = [ | ||
export const EVENTS = [ | ||
"dragStart", | ||
"selectStart", | ||
@@ -10,0 +11,0 @@ "select", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
297271
3753