Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

smooth-dnd

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smooth-dnd - npm Package Compare versions

Comparing version 0.4.8 to 0.4.9

2

dist/index.js

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SmoothDnD=t():e.SmoothDnD=t()}(this,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=10)}([function(e,t,n){"use strict";var o,r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o=function(){return this}();try{o=o||Function("return this")()||(0,eval)("this")}catch(e){"object"===("undefined"==typeof window?"undefined":r(window))&&(o=window)}e.exports=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.containerInstance="smooth-dnd-container-instance",t.containersInDraggable="smooth-dnd-containers-in-draggable",t.defaultGroupName="@@smooth-dnd-default-group@@",t.wrapperClass="smooth-dnd-draggable-wrapper",t.defaultGrabHandleClass="smooth-dnd-default-grap-handle",t.animationClass="animated",t.translationValue="__smooth_dnd_draggable_translation_value",t.visibilityValue="__smooth_dnd_draggable_visibility_value",t.ghostClass="smooth-dnd-ghost",t.containerClass="smooth-dnd-container",t.extraSizeForInsertion="smooth-dnd-extra-size-for-insertion",t.stretcherElementClass="smooth-dnd-stretcher-element",t.stretcherElementInstance="smooth-dnd-stretcher-instance",t.isDraggableDetached="smoth-dnd-is-draggable-detached",t.disbaleTouchActions="smooth-dnd-disable-touch-action",t.noUserSelectClass="smooth-dnd-no-user-select"},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});t.getIntersection=function(e,t){return{left:Math.max(e.left,t.left),top:Math.max(e.top,t.top),right:Math.min(e.right,t.right),bottom:Math.min(e.bottom,t.bottom)}};var n=t.getIntersectionOnAxis=function(e,t,n){return"x"===n?{left:Math.max(e.left,t.left),top:e.top,right:Math.min(e.right,t.right),bottom:e.bottom}:{left:e.left,top:Math.max(e.top,t.top),right:e.right,bottom:Math.min(e.bottom,t.bottom)}},o=t.getContainerRect=function(e){var t=e.getBoundingClientRect(),n={left:t.left,right:t.right+10,top:t.top,bottom:t.bottom};if(a(e,"x")&&!i(e,"x")){var o=n.right-n.left;n.right=n.right+e.scrollWidth-o}if(a(e,"y")&&!i(e,"y")){var r=n.bottom-n.top;n.bottom=n.bottom+e.scrollHeight-r}return n},r=(t.getScrollingAxis=function(t){var n=e.getComputedStyle(t),o=n.overflow;if("auto"===o||"scroll"===o)return"xy";var r=n["overflow-x"],i="auto"===r||"scroll"===r,a=n["overflow-y"];return(i?"x":"")+("auto"===a||"scroll"===a?"y":"")||null},t.isScrolling=function(t,n){var o=e.getComputedStyle(t),r=o.overflow,i=o["overflow-"+n];return"auto"===r||"scroll"===r||("auto"===i||"scroll"===i)}),i=t.isScrollingOrHidden=function(t,n){var o=e.getComputedStyle(t),r=o.overflow,i=o["overflow-"+n];return"auto"===r||"scroll"===r||"hidden"===r||("auto"===i||"scroll"===i||"hidden"===i)},a=t.hasBiggerChild=function(e,t){return"x"===t?e.scrollWidth>e.clientWidth:e.scrollHeight>e.clientHeight};t.hasScrollBar=function(e,t){return a(e,t)&&r(e,t)},t.getVisibleRect=function(e,t){var r=e,l=t||o(e);for(r=e.parentElement;r;)a(r,"x")&&i(r,"x")&&(l=n(l,r.getBoundingClientRect(),"x")),a(r,"y")&&i(r,"y")&&(l=n(l,r.getBoundingClientRect(),"y")),r=r.parentElement;return l},t.listenScrollParent=function(t,n){var o=[];return setTimeout(function(){for(var i=t;i;)(r(i,"x")||r(i,"y"))&&(i.addEventListener("scroll",n),o.push(i)),i=i.parentElement;e.addEventListener("scroll",n)},10),{dispose:function(){o.forEach(function(e){e.removeEventListener("scroll",n)}),e.removeEventListener("scroll",n)}}},t.hasParent=function(e,t){for(var n=e;n;){if(n===t)return!0;n=n.parentElement}return!1},t.getParent=function(e,t){for(var n=e;n;){if(n.matches(t))return n;n=n.parentElement}return null},t.hasClass=function(e,t){return e.className.split(" ").map(function(e){return e}).indexOf(t)>-1},t.addClass=function(e,t){if(e){var n=e.className.split(" ").filter(function(e){return e});-1===n.indexOf(t)&&(n.push(t),e.className=n.join(" "))}},t.removeClass=function(e,t){if(e){var n=e.className.split(" ").filter(function(e){return e&&e!==t});e.className=n.join(" ")}},t.debounce=function(e,t,n){var o=null;return function(){for(var r=arguments.length,i=Array(r),a=0;a<r;a++)i[a]=arguments[a];o&&clearTimeout(o),n&&!o?e.call.apply(e,[void 0].concat(i)):o=setTimeout(function(){o=null,e.call.apply(e,[void 0].concat(i))},t)}},t.removeChildAt=function(e,t){return e.removeChild(e.children[t])},t.addChildAt=function(e,t,n){n>=e.children.lenght?e.appendChild(t):e.insertBefore(t,e.children[n])},t.isMobile=function(){return"undefined"!=typeof window&&!!(e.navigator.userAgent.match(/Android/i)||e.navigator.userAgent.match(/webOS/i)||e.navigator.userAgent.match(/iPhone/i)||e.navigator.userAgent.match(/iPad/i)||e.navigator.userAgent.match(/iPod/i)||e.navigator.userAgent.match(/BlackBerry/i)||e.navigator.userAgent.match(/Windows Phone/i))},t.clearSelection=function(){e.getSelection?e.getSelection().empty?e.getSelection().empty():e.getSelection().removeAllRanges&&e.getSelection().removeAllRanges():e.document.selection&&e.document.selection.empty()}}).call(this,n(0))},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.domDropHandler=function(t){var n=t.element,i=t.draggables;t.layout,t.options;return function(t,a){var l=t.removedIndex,s=t.addedIndex,u=t.droppedElement,c=null;if(null!==l&&(c=(0,o.removeChildAt)(n,l),i.splice(l,1)),null!==s){var d=e.document.createElement("div");d.className=""+r.wrapperClass,d.appendChild(c.firstElementChild||u),d[r.containersInDraggable]=[],(0,o.addChildAt)(n,d,s),s>=i.length?i.push(d):i.splice(s,0,d)}a&&a(t)}},t.reactDropHandler=function(){return{handler:function(e){e.element,e.draggables,e.layout,e.options;return function(e,t){t&&t(e)}}}};var o=n(2),r=n(1)}).call(this,n(0))},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t,n,l){t[r.extraSizeForInsertion]=0;var s=l,u=function(e){return{get:function(t,n){var o=e[n];return t[o||n]},set:function(t,n,o){requestAnimationFrame(function(){t[e[n]]=e.setters[n]?e.setters[n](o):o})}}}("horizontal"===n?i:a),c={translation:0},d=null;e.addEventListener("resize",function(){m(t)}),setTimeout(function(){g()},10);var f=o.listenScrollParent(t,function(){m(t),d&&d()});function g(){m(t),function(e){var t=e.getBoundingClientRect();c.scaleX=e.offsetWidth?(t.right-t.left)/e.offsetWidth:1,c.scaleY=e.offsetHeight?(t.bottom-t.top)/e.offsetHeight:1}(t)}var p=void 0;function m(e){c.rect=o.getContainerRect(e),c.visibleRect=o.getVisibleRect(e,c.rect)}function v(e){return u.get(e,"size")*u.get(c,"scale")}function h(e){return u.get(e,"dragPosition")}function y(e,t){var o=c.visibleRect,r=o.left,i=o.top,a=o.right,l=o.bottom;l-i<2&&(l=i+30);var s=c.rect;return"vertical"===n?e>s.left&&e<s.right&&t>i&&t<l:e>r&&e<a&&t>s.top&&t<s.bottom}return{getSize:v,getContainerRectangles:function(){return{rect:c.rect,visibleRect:c.visibleRect}},getBeginEndOfDOMRect:function(e){return{begin:u.get(e,"begin"),end:u.get(e,"end")}},getBeginEndOfContainer:function(){var e=u.get(c.rect,"begin")+c.translation,t=u.get(c.rect,"end")+c.translation;return{begin:e,end:t}},getBeginEndOfContainerVisibleRect:function(){var e=u.get(c.visibleRect,"begin")+c.translation,t=u.get(c.visibleRect,"end")+c.translation;return{begin:e,end:t}},getBeginEnd:function(e){var n=function(e){return(u.get(e,"distanceToParent")+(e[r.translationValue]||0))*u.get(c,"scale")}(e)+(u.get(c.rect,"begin")+c.translation)-u.get(t,"scrollValue");return{begin:n,end:n+v(e)*u.get(c,"scale")}},getAxisValue:h,setTranslation:function(e,t){t?u.set(e.style,"translate",t):e.style.removeProperty("transform");e[r.translationValue]=t,e[r.containersInDraggable]&&setTimeout(function(){e[r.containersInDraggable].forEach(function(e){!function e(t){t.layout.invalidateRects();t.onTranslated();t.getChildContainers()&&t.getChildContainers().forEach(function(t){return e(t)})}(e)})},s+20)},getTranslation:function(e){return e[r.translationValue]},setVisibility:function(e,t){void 0!==e[r.visibilityValue]&&e[r.visibilityValue]===t||(t?e.style.removeProperty("visibility"):e.style.visibility="hidden",e[r.visibilityValue]=t)},isVisible:function(e){return void 0===e[r.visibilityValue]||e[r.visibilityValue]},isInVisibleRect:y,dispose:function(){f&&f.dispose();p&&(p.parentNode.removeChild(p),p=null)},getContainerScale:function(){return{scaleX:c.scaleX,scaleY:c.scaleY}},setScrollListener:function(e){d=e},setSize:function(e,t){u.set(e,"setSize",t)},getTopLeftOfElementBegin:function(e){var t=0,o=0;"horizontal"===n?(o=e,t=c.rect.top):(o=c.rect.left,t=e);return{top:t,left:o}},getScrollSize:function(e){return u.get(e,"scrollSize")},getScrollValue:function(e){return u.get(e,"scrollValue")},setScrollValue:function(e,t){return u.set(e,"scrollValue",t)},invalidate:g,invalidateRects:function(){m(t)},getPosition:function(e){return y(e.x,e.y)?h(e):null}}};var o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(n(2)),r=n(1);var i={size:"offsetWidth",distanceToParent:"offsetLeft",translate:"transform",begin:"left",end:"right",dragPosition:"x",scrollSize:"scrollWidth",offsetSize:"offsetWidth",scrollValue:"scrollLeft",scale:"scaleX",setSize:"width",setters:{translate:function(e){return"translate3d("+e+"px, 0, 0)"}}},a={size:"offsetHeight",distanceToParent:"offsetTop",translate:"transform",begin:"top",end:"bottom",dragPosition:"y",scrollSize:"scrollHeight",offsetSize:"offsetHeight",scrollValue:"scrollTop",scale:"scaleY",setSize:"height",setters:{translate:function(e){return"translate3d(0,"+e+"px, 0)"}}}}).call(this,n(0))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(2);var r=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y",n=!1,o=null,r=null,i=null,a=null;return{animate:function(l,s){i=l,a=s,(n=!0)&&function n(){null===o&&(o=requestAnimationFrame(function(l){null===r&&(r=l);var s=l-r;r=l;var u=s/1e3*a;(function(e,t,n){e&&("x"===t?e.scrollLeft+=n:e.scrollTop+=n)})(e,t,u="begin"===i?0-u:u),o=null,n()}))}()},stop:function(){n&&(cancelAnimationFrame(o),n=!1,r=null,o=null)}}};function i(e){var t={element:e,rect:(0,o.getVisibleRect)(e,e.getBoundingClientRect()),descendants:[],invalidate:n,axis:null};function n(){t.rect=(0,o.getVisibleRect)(e,e.getBoundingClientRect()),t.descendants.forEach(function(e){return e.invalidate()})}return e.addEventListener("scroll",function(){n()}),t}function a(e){return Object.assign(e,r(e.element,e.axis))}t.default=function(e){var t,n,r,l=(t=e.map(function(e){return e.element}),n=[],r=null,t.forEach(function(e){var t=e;for(r=null;t;){var a=(0,o.getScrollingAxis)(t);if(a&&!n.some(function(e){return e.element===t})){var l=i(t);r&&l.descendants.push(r),r=l,"xy"===a?(n.push(Object.assign({},l,{axis:"x"})),n.push(Object.assign({},l,{axis:"y"},{descendants:[]}))):n.push(Object.assign({},l,{axis:a}))}t=t.parentElement}}),n).map(a);return function(e){var t=e.draggableInfo,n=e.reset;if(l.length){if(n)return l.forEach(function(e){return e.stop()}),null;l.forEach(function(e){var n=function(e,t){var n=t.rect,o=n.left,r=n.right,i=n.top,a=n.bottom,l=e.x,s=e.y;if(l<o||l>r||s<i||s>a)return null;var u=void 0,c=void 0,d=void 0;return"x"===t.axis?(u=o,c=r,d=l):(u=i,c=a,d=s),c-d<100?{direction:"end",speedFactor:(100-(c-d))/100}:d-u<100?{direction:"begin",speedFactor:(100-(d-u))/100}:void 0}(t.mousePosition,e);n?e.animate(n.direction,1500*n.speedFactor):e.stop()})}}}},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.addStyleToHead=void 0;var o,r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(n(1));function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l={overflow:"hidden",display:"block"},s={height:"100%",display:"inline-block","vertical-align":"top","white-space":"normal"},u=(a(o={},"."+i.containerClass,{position:"relative"}),a(o,"."+i.containerClass+" *",{"box-sizing":"border-box"}),a(o,"."+i.containerClass+".horizontal",{"white-space":"nowrap"}),a(o,"."+i.containerClass+".horizontal > ."+i.wrapperClass,s),a(o,"."+i.containerClass+".vertical > ."+i.wrapperClass,l),a(o,"."+i.wrapperClass,{}),a(o,"."+i.wrapperClass+".horizontal",s),a(o,"."+i.wrapperClass+".vertical",l),a(o,"."+i.wrapperClass+".animated",{transition:"transform ease"}),a(o,"."+i.ghostClass+" *",{"box-sizing":"border-box"}),a(o,"."+i.ghostClass+".animated",{transition:"all ease-in-out"}),a(o,"."+i.disbaleTouchActions+" *",{"touch-actions":"none","-ms-touch-actions":"none"}),a(o,"."+i.noUserSelectClass+" *",{"-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none"}),o);t.addStyleToHead=function(){if("undefined"!=typeof window){var t=e.document.head||e.document.getElementsByTagName("head")[0],n=e.document.createElement("style"),o=function e(t){return Object.keys(t).reduce(function(n,o){var i=t[o];return"object"===(void 0===i?"undefined":r(i))?""+n+o+"{"+e(i)+"}":""+n+o+":"+i+";"},"")}(u);n.type="text/css",n.styleSheet?n.styleSheet.cssText=o:n.appendChild(e.document.createTextNode(o)),t.appendChild(n)}}}).call(this,n(0))},function(e,t,n){"use strict";(function(e){var t;(t=e.Node||e.Element)&&t.prototype&&!t.prototype.matches&&(t.prototype.matches=t.prototype.matchesSelector||t.prototype.mozMatchesSelector||t.prototype.msMatchesSelector||t.prototype.oMatchesSelector||t.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),n=t.length;--n>=0&&t.item(n)!==this;);return n>-1}),function(e){e&&e.prototype&&null==e.prototype.firstElementChild&&Object.defineProperty(e.prototype,"firstElementChild",{get:function(){for(var e,t=this.childNodes,n=0;e=t[n++];)if(1===e.nodeType)return e;return null}})}(e.Node||e.Element),Array.prototype.some||(Array.prototype.some=function(e){if(null==this)throw new TypeError("Array.prototype.some called on null or undefined");if("function"!=typeof e)throw new TypeError;for(var t=Object(this),n=t.length>>>0,o=arguments.length>=2?arguments[1]:void 0,r=0;r<n;r++)if(r in t&&e.call(o,t[r],r,t))return!0;return!1})}).call(this,n(0))},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),n(7);var o,r=u(n(2)),i=u(n(1)),a=n(6),l=n(5),s=(o=l)&&o.__esModule?o:{default:o};function u(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}var c=["mousedown","touchstart"],d=["mousemove","touchmove"],f=["mouseup","touchend"],g=null,p=null,m=null,v=null,h=[],y=!1,b=null,C=null,E=null,x=r.isMobile();function S(){"undefined"!=typeof window&&c.forEach(function(t){e.document.addEventListener(t,w,{passive:!1})})}function O(){return p&&p.parentElement||e.document.body}var D=function(){var t=void 0,n=void 0,o=void 0,r=null,i=1,a=5;function l(e){var o=P(e),r=o.clientX,l=o.clientY;if(n)(Math.abs(t.clientX-r)>a||Math.abs(t.clientY-l)>a)&&c();else if(Math.abs(t.clientX-r)>i||Math.abs(t.clientY-l)>i)return g()}function s(){c()}function u(){c()}function c(){clearTimeout(r),d.forEach(function(t){return e.document.removeEventListener(t,l)},{passive:!1}),f.forEach(function(t){return e.document.removeEventListener(t,s)},{passive:!1}),e.document.removeEventListener("drag",u,{passive:!1})}function g(){clearTimeout(r),c(),o()}return function(i,a,c){t=P(i),o=c,(n=a||(x?200:0))&&(r=setTimeout(g,n)),d.forEach(function(t){return e.document.addEventListener(t,l)},{passive:!1}),f.forEach(function(t){return e.document.addEventListener(t,s)},{passive:!1}),e.document.addEventListener("drag",u,{passive:!1})}}();function w(t){var n=P(t);if(!y&&(p=r.getParent(n.target,"."+i.wrapperClass))){var o=r.getParent(p,"."+i.containerClass),a=h.filter(function(e){return e.element===o})[0],l=a.getOptions().dragHandleSelector,s=a.getOptions().nonDragAreaSelector,u=!0;l&&!r.getParent(n.target,l)&&(u=!1),s&&r.getParent(n.target,s)&&(u=!1),u&&D(n,a.getOptions().dragBeginDelay,function(){r.clearSelection(),A(n),d.forEach(function(t){e.document.addEventListener(t,T,{passive:!1})}),f.forEach(function(t){e.document.addEventListener(t,I,{passive:!1})})})}}function I(){d.forEach(function(t){e.document.removeEventListener(t,T,{passive:!1})}),f.forEach(function(t){e.document.removeEventListener(t,I,{passive:!1})}),C({reset:!0}),v&&function(e){function t(){r.removeClass(m.ghost,"animated"),m.ghost.style.transitionDuration=null,O().removeChild(m.ghost),e()}function n(e,n,o){var i=e.top,a=e.left;r.addClass(m.ghost,"animated"),o&&r.addClass(m.ghost.firstElementChild,o),m.ghost.style.transitionDuration=n+"ms",m.ghost.style.left=a+"px",m.ghost.style.top=i+"px",setTimeout(function(){t()},n+20)}if(v.targetElement){var o=h.filter(function(e){return e.element===v.targetElement})[0];!(d=o.getOptions()).shouldAnimateDrop||d.shouldAnimateDrop(v.container.getOptions(),v.payload)?n(o.getDragResult().shadowBeginEnd.rect,Math.max(150,o.getOptions().animationDuration/2),o.getOptions().dropClass):t()}else{var i=h.filter(function(e){return e===v.container})[0];if("move"===i.getOptions().behaviour&&i.getDragResult()){var a=i.getDragResult(),l=a.removedIndex,s=a.elementSize,u=i.layout;i.getTranslateCalculator({dragResult:{removedIndex:l,addedIndex:l,elementSize:s}});var c=l>0?u.getBeginEnd(i.draggables[l-1]).end:u.getBeginEndOfContainer().begin;n(u.getTopLeftOfElementBegin(c),i.getOptions().animationDuration,i.getOptions().dropClass)}else r.addClass(m.ghost,"animated"),m.ghost.style.transitionDuration=i.getOptions().animationDuration+"ms",m.ghost.style.opacity="0",m.ghost.style.transform="scale(0.90)",setTimeout(function(){t()},i.getOptions().animationDuration)}var d}(function(){r.removeClass(e.document.body,i.disbaleTouchActions),r.removeClass(e.document.body,i.noUserSelectClass),R(!1),(g||[]).forEach(function(e){e.handleDrop(v)}),g=null,p=null,m=null,v=null,y=!1,null,E=null,b=null})}function P(e){return e.touches?e.touches[0]:e}function R(e){h.forEach(function(t){var n=e?t.getOptions().onDragStart:t.getOptions().onDragEnd;if(n){var o={isSource:t===v.container,payload:v.payload};t.isDragRelevant(v.container,v.payload)?o.willAcceptDrop=!0:o.willAcceptDrop=!1,n(o)}})}function A(t,n){y=!0;var o=h.filter(function(e){return p.parentElement===e.element})[0];o.setDraggables(),o,E=o.getOptions().lockAxis?o.getOptions().lockAxis.toLowerCase():null,v=function(e){var t=h.filter(function(t){return e.parentElement===t.element})[0],n=t.draggables.indexOf(e);return{container:t,element:e,elementIndex:n,payload:t.getOptions().getChildPayload?t.getOptions().getChildPayload(n):void 0,targetElement:null,position:{x:0,y:0},groupName:t.getOptions().groupName}}(p),m=function(e,t,n,o){var a=t.x,l=t.y,s=n.getScale(),u=(s.scaleX,s.scaleY,e.getBoundingClientRect()),c=u.left,d=u.top,f=u.right,g=u.bottom,p=c+(f-c)/2,m=d+(g-d)/2,v=e.cloneNode(!0);return v.style.zIndex=1e3,v.style.boxSizing="border-box",v.style.position="fixed",v.style.left=c+"px",v.style.top=d+"px",v.style.width=f-c+"px",v.style.height=g-d+"px",v.style.overflow="visible",v.style.transition=null,v.style.removeProperty("transition"),v.style.pointerEvents="none",setTimeout(function(){n.getOptions().dragClass&&r.addClass(v.firstElementChild,n.getOptions().dragClass)}),r.addClass(v,n.getOptions().orientation),r.addClass(v,i.ghostClass),{ghost:v,centerDelta:{x:p-a,y:m-l},positionDelta:{left:c-a,top:d-l}}}(p,{x:t.clientX,y:t.clientY},v.container),v.position={x:t.clientX+m.centerDelta.x,y:t.clientY+m.centerDelta.y},v.mousePosition={x:t.clientX,y:t.clientY},r.addClass(e.document.body,i.disbaleTouchActions),r.addClass(e.document.body,i.noUserSelectClass),g=h.filter(function(e){return e.isDragRelevant(o,v.payload)}),b=function(e){var t=e;return function(e){t.forEach(function(t){return t.handleDrag(e)}),C({draggableInfo:e})}}(g),C=function(e,t){return e.getOptions().autoScrollEnabled?(0,s.default)(t):function(){return null}}(o,g),g.forEach(function(e){return e.prepareDrag(e,g)}),R(!0),b(v),O().appendChild(m.ghost)}function T(e){e.preventDefault();var t=P(e);v?(E?"y"===E?(m.ghost.style.top=t.clientY+m.positionDelta.top+"px",v.position.y=t.clientY+m.centerDelta.y,v.mousePosition.y=t.clientY):"x"===E&&(m.ghost.style.left=t.clientX+m.positionDelta.left+"px",v.position.x=t.clientX+m.centerDelta.x,v.mousePosition.x=t.clientX):(m.ghost.style.left=t.clientX+m.positionDelta.left+"px",m.ghost.style.top=t.clientY+m.positionDelta.top+"px",v.position.x=t.clientX+m.centerDelta.x,v.position.y=t.clientY+m.centerDelta.y,v.mousePosition.x=t.clientX,v.mousePosition.y=t.clientY),b(v)):A(t)}(0,a.addStyleToHead)(),t.default=(S(),{register:function(e){h.push(e)},unregister:function(e){h.splice(h.indexOf(e),1)}})}).call(this,n(0))},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});var o=s(n(8)),r=s(n(4)),i=n(2),a=n(3),l=n(1);function s(e){return e&&e.__esModule?e:{default:e}}var u={groupName:null,behaviour:"move",orientation:"vertical",getChildPayload:null,animationDuration:250,autoScrollEnabled:!0,shouldAcceptDrop:null,shouldAnimateDrop:null};function c(e,t,n){t?((0,i.addClass)(e,l.animationClass),e.style.transitionDuration=n+"ms"):((0,i.removeClass)(e,l.animationClass),e.style.removeProperty("transition-duration"))}function d(e){return e?e[l.containerInstance]:null}function f(t){if(L.wrapChild)return L.wrapChild(t);var n=e.document.createElement("div");return n.className=""+l.wrapperClass,t.parentElement.insertBefore(n,t),n.appendChild(t),n}function g(e){var t=[];return Array.prototype.map.call(e.children,function(n){if(n.nodeType===Node.ELEMENT_NODE){var o=n;(0,i.hasClass)(n,l.wrapperClass)||(o=f(n)),o[l.containersInDraggable]=[],o[l.translationValue]=0,t.push(o)}else e.removeChild(n)}),t}function p(e){var t=e.layout;return function(e,n){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return function e(n,o,r,i){var a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(i<r)return r;if(r===i){var l=t.getBeginEnd(n[r]),s=l.begin,u=l.end;return o>s&&o<=u?a?o<(u+s)/2?r:r+1:r:null}var c=Math.floor((i+r)/2),d=t.getBeginEnd(n[c]),f=d.begin,g=d.end;return o<f?e(n,o,r,c-1,a):o>g?e(n,o,c+1,i,a):a?o<(g+f)/2?c:c+1:c}(e,n,0,e.length-1,o)}}function m(e){var t=e.element,n=e.draggables,o=e.layout,r=e.options,i=function(e){var t=e.element,n=e.draggables,o=e.layout;return e.options,function(){n.forEach(function(e){c(e,!1),o.setTranslation(e,0),o.setVisibility(e,!0),e[l.containersInDraggable]=[]}),t[l.stretcherElementInstance]&&(t[l.stretcherElementInstance].parentNode.removeChild(t[l.stretcherElementInstance]),t[l.stretcherElementInstance]=null)}}({element:t,draggables:n,layout:o,options:r}),s=(L.dropHandler||a.domDropHandler)({element:t,draggables:n,layout:o,options:r});return function(e,t){var n=t.addedIndex,o=t.removedIndex;if(i(),e.targetElement){var a={removedIndex:o,addedIndex:null!==n?null!==o&&o<n?n-1:n:null,payload:e.payload,droppedElement:e.element.firstElementChild};s(a,r.onDrop)}}}function v(e,t){var n=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u;return Object.assign({},u,e)}(t),o=g(e,n.orientation,n.animationDuration);return(0,i.addClass)(e,l.containerClass+" "+n.orientation),{element:e,draggables:o,options:n,layout:(0,r.default)(e,n.orientation,n.animationDuration)}}function h(e,t){var n=function(e,t){for(var n=e.element;n;){var o=d(n.parentElement);if(o&&t.indexOf(o)>-1)return{container:o,draggable:n};n=n.parentElement}return null}(e,t);n&&(n.container.getChildContainers().push(e),e.setParentContainer(n.container),n.draggable[l.containersInDraggable].push(e))}function y(e){e.draggables;var t=e.element,n=e.options,o=null;return function(e){var r=e.draggableInfo,i=(e.dragResult,o);return null==o&&r.container.element===t&&"copy"!==n.behaviour&&(i=o=r.elementIndex),{removedIndex:i}}}function b(e){var t=e.draggables,n=e.layout;return function(e){e.draggableInfo;var o=e.dragResult;null!==o.removedIndex&&n.setVisibility(t[o.removedIndex],!1)}}function C(e){var t=e.element,n=e.layout;return function(e){var o=e.draggableInfo;return{pos:d(t).isPosInChildContainer()?null:n.getPosition(o.position)}}}function E(e){var t=e.element,n=!1;return function(e){e.draggableInfo;var o=e.dragResult;d(t).getParentContainer()&&n!==(null!==o.pos)&&(n=null!==o.pos,d(t).getParentContainer().onChildPositionCaptured(n))}}function x(e){var t=e.layout,n=null;return function(e){var o=e.draggableInfo;return null===e.dragResult.pos?n=null:{elementSize:n=n||t.getSize(o.element)}}}function S(e){var t=e.element;return function(e){var n=e.draggableInfo,o=e.dragResult;!function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t&&n?e.targetElement=t:e.targetElement===t&&(e.targetElement=null)}(n,t,!!o.pos)}}function O(e){e.draggables,e.layout;return function(e){return null!==e.dragResult.pos?{addedIndex:0}:{addedIndex:null}}}function D(e){e.draggables;var t=e.layout,n=null;return function(e){var o=e.dragResult.addedIndex;if(o!==n){n=o;var r=t.getBeginEndOfContainer(),i=r.begin,a=r.end;return{shadowBeginEnd:{rect:t.getTopLeftOfElementBegin(i,a)}}}}}function w(e){var t=T(e);return function(e){var n=e.draggableInfo,o=e.dragResult;return n.invalidateShadow?t({draggableInfo:n,dragResult:o}):null}}function I(e){var t,n,o,r=(n=(t=e).draggables,o=p({layout:t.layout}),function(e){var t=e.dragResult,r=t.shadowBeginEnd,i=t.pos;if(!r){var a=o(n,i,!0);return null!==a?a:n.length}return r.begin+r.beginAdjustment<=i&&r.end>=i?null:i<r.begin+r.beginAdjustment?o(n,i):i>r.end?o(n,i)+1:n.length});return function(e){var t=e.dragResult,n=null;return null!==t.pos&&null===(n=r({dragResult:t}))&&(n=t.addedIndex),{addedIndex:n}}}function P(){var e=null;return function(t){var n=t.dragResult,o=n.addedIndex,r=n.shadowBeginEnd;o!==e&&null!==e&&r&&(r.beginAdjustment=0),e=o}}function R(t){var n=t.element,o=t.draggables,r=t.layout,i=t.options,a=null,s=!1;return function(t){var u=t.dragResult,c=u.addedIndex,d=u.removedIndex,f=u.elementSize;if(null===d)if(null!==c){if(!s){var g=r.getBeginEndOfContainer(),p=r.getScrollSize(n)>r.getSize(n)?g.begin+r.getScrollSize(n)-r.getScrollValue(n):g.end,m=o.length>0?r.getBeginEnd(o[o.length-1]).end-o[o.length-1][l.translationValue]:g.begin;if(m+f>p){(a=e.document.createElement("div")).className=l.stretcherElementClass+" "+i.orientation;var v=f+m-p;r.setSize(a.style,v+"px"),n.appendChild(a),n[l.stretcherElementInstance]=a}s=!0,setTimeout(function(){r.invalidateRects()},100)}}else{if(a){r.setTranslation(a,0);var h=a;a=null,n.removeChild(h),n[l.stretcherElementInstance]=null}s=!1,setTimeout(function(){r.invalidateRects()},100)}}}function A(e){e.element;var t=e.draggables,n=e.layout,o=null,r=null;return function(e){var i=e.dragResult,a=i.addedIndex,l=i.removedIndex,s=i.elementSize;if(a!==o||l!==r){for(var u=0;u<t.length;u++)if(u!==l){var c=t[u],d=0;null!==l&&l<u&&(d-=n.getSize(t[l])),null!==a&&a<=u&&(d+=s),n.setTranslation(c,d)}return o=a,r=l,{addedIndex:a,removedIndex:l}}}}function T(e){var t=e.draggables,n=e.layout,o=null;return function(e){var r=e.draggableInfo,i=e.dragResult,a=i.addedIndex,l=i.removedIndex,s=i.elementSize,u=i.pos,c=i.shadowBeginEnd;if(null!==u){if(null===a||!r.invalidateShadow&&a===o)return null;o&&(o=a);var d=a-1,f=0,g=null,p=null;if(d===l&&d--,d>-1){var m=n.getSize(t[d]);if(p=n.getBeginEnd(t[d]),s<m){var v=(m-s)/2;f=p.end-v}else f=p.end}else p={end:n.getBeginEndOfContainer().begin};var h=1e4,y=a;if(y===l&&y++,y<t.length){var b=n.getSize(t[y]);if(g=n.getBeginEnd(t[y]),s<b){var C=(b-s)/2;h=g.begin+C}else h=g.begin}else g={begin:n.getContainerRectangles().end};return{shadowBeginEnd:{begin:f,end:h,rect:p&&g?n.getTopLeftOfElementBegin(p.end,g.begin):null,beginAdjustment:c?c.beginAdjustment:0}}}return o=null,{shadowBeginEnd:null}}}function _(){var e=null;return function(t){var n=t.dragResult,o=n.pos,r=n.addedIndex,i=n.shadowBeginEnd;t.draggableInfo.invalidateShadow;if(null!==o){if(null!=r&&null===e){if(o<i.begin){var a=o-i.begin-5;i.beginAdjustment=a}e=r}}else e=null}}function z(e){var t=e.options,n=!1;return function(e){var o=!!e.dragResult.pos;if(o!==n){if(n=o,!o)return t.onDragLeave&&t.onDragLeave(),{dragLeft:!0};t.onDragEnter&&t.onDragEnter()}}}function B(e){return"drop-zone"===e.options.behaviour?M(e)(y,b,C,E,x,S,O,D,z):M(e)(y,b,C,E,x,S,w,I,P,R,A,T,_,z)}function M(e){return function(){for(var t=arguments.length,n=Array(t),o=0;o<t;o++)n[o]=arguments[o];var r=n.map(function(t){return t(e)}),i=null;return function(e){return i=r.reduce(function(t,n){return Object.assign(t,n({draggableInfo:e,dragResult:t}))},i||{addedIndex:null,removedIndex:null,elementSize:null,pos:null,shadowBeginEnd:null})}}}function j(e){return function(t){var n=null,o=null,r=v(e,t),a=B(r),s=m(r),u=null,d=!1,p=[];function y(){null!==o&&(o.invalidateShadow=!0,n=a(o),o.invalidateShadow=!1)}function b(e){d=e,u&&(u.onChildPositionCaptured(e),o&&(n=a(o)))}function C(e,t,n){for(var o=g(t,n.orientation,n.animationDuration),r=0;r<o.length;r++)e[r]=o[r];for(var i=0;i<e.length-o.length;i++)e.pop()}return r.layout.setScrollListener(function(){y()}),{element:e,draggables:r.draggables,isDragRelevant:function(e){var t=e.element,n=e.options;return function(e,o){if(n.shouldAcceptDrop)return n.shouldAcceptDrop(e.getOptions(),o);var r=e.getOptions();return"copy"!==n.behaviour&&(0,i.getParent)(t,"."+l.wrapperClass)!==e.element&&(e.element===t||!(!r.groupName||r.groupName!==n.groupName))}}(r),getScale:r.layout.getContainerScale,layout:r.layout,getChildContainers:function(){return p},onChildPositionCaptured:b,dispose:function(e){var t;t=e.element,Array.prototype.map.call(t.children,function(e){if(e.nodeType===Node.ELEMENT_NODE){var n=e;(0,i.hasClass)(e,l.wrapperClass)&&(t.insertBefore(n,f.firstElementChild),t.removeChild(n))}})},prepareDrag:function(e,t){var n=e.element,o=r.draggables,i=e.getOptions();C(o,n,i),e.layout.invalidateRects(),h(e,t),o.forEach(function(e){return c(e,!0,i.animationDuration)})},isPosInChildContainer:function(){return d},handleDrag:function(e){return o=e,(n=a(e)).dragLeft&&"drop-zone"!==r.options.behaviour&&(n.dragLeft=!1,setTimeout(function(){n&&A(r)({dragResult:n})},20)),n},handleDrop:function(e){o=null,b(!1),a=B(r),s(e,n),n=null,u=null,p=[]},getDragResult:function(){return n},getTranslateCalculator:function(){return A(r).apply(void 0,arguments)},setParentContainer:function(e){u=e},getParentContainer:function(){return u},onTranslated:function(){y()},getOptions:function(){return r.options},setDraggables:function(){C(r.draggables,e,r.options)}}}}function L(e,t){var n=j(e)(t);return e[l.containerInstance]=n,o.default.register(n),{dispose:function(){o.default.unregister(n),n.layout.dispose(),n.dispose(n)}}}t.default=L}).call(this,n(0))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dropHandlers=t.constants=void 0;var o,r=n(9),i=(o=r)&&o.__esModule?o:{default:o},a=s(n(1)),l=s(n(3));function s(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}t.default=i.default,t.constants=a,t.dropHandlers=l}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SmoothDnD=t():e.SmoothDnD=t()}(this,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=10)}([function(e,t,n){"use strict";var o,r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};o=function(){return this}();try{o=o||Function("return this")()||(0,eval)("this")}catch(e){"object"===("undefined"==typeof window?"undefined":r(window))&&(o=window)}e.exports=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.containerInstance="smooth-dnd-container-instance",t.containersInDraggable="smooth-dnd-containers-in-draggable",t.defaultGroupName="@@smooth-dnd-default-group@@",t.wrapperClass="smooth-dnd-draggable-wrapper",t.defaultGrabHandleClass="smooth-dnd-default-grap-handle",t.animationClass="animated",t.translationValue="__smooth_dnd_draggable_translation_value",t.visibilityValue="__smooth_dnd_draggable_visibility_value",t.ghostClass="smooth-dnd-ghost",t.containerClass="smooth-dnd-container",t.extraSizeForInsertion="smooth-dnd-extra-size-for-insertion",t.stretcherElementClass="smooth-dnd-stretcher-element",t.stretcherElementInstance="smooth-dnd-stretcher-instance",t.isDraggableDetached="smoth-dnd-is-draggable-detached",t.disbaleTouchActions="smooth-dnd-disable-touch-action",t.noUserSelectClass="smooth-dnd-no-user-select"},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});t.getIntersection=function(e,t){return{left:Math.max(e.left,t.left),top:Math.max(e.top,t.top),right:Math.min(e.right,t.right),bottom:Math.min(e.bottom,t.bottom)}};var n=t.getIntersectionOnAxis=function(e,t,n){return"x"===n?{left:Math.max(e.left,t.left),top:e.top,right:Math.min(e.right,t.right),bottom:e.bottom}:{left:e.left,top:Math.max(e.top,t.top),right:e.right,bottom:Math.min(e.bottom,t.bottom)}},o=t.getContainerRect=function(e){var t=e.getBoundingClientRect(),n={left:t.left,right:t.right+10,top:t.top,bottom:t.bottom};if(a(e,"x")&&!i(e,"x")){var o=n.right-n.left;n.right=n.right+e.scrollWidth-o}if(a(e,"y")&&!i(e,"y")){var r=n.bottom-n.top;n.bottom=n.bottom+e.scrollHeight-r}return n},r=(t.getScrollingAxis=function(t){var n=e.getComputedStyle(t),o=n.overflow;if("auto"===o||"scroll"===o)return"xy";var r=n["overflow-x"],i="auto"===r||"scroll"===r,a=n["overflow-y"];return(i?"x":"")+("auto"===a||"scroll"===a?"y":"")||null},t.isScrolling=function(t,n){var o=e.getComputedStyle(t),r=o.overflow,i=o["overflow-"+n];return"auto"===r||"scroll"===r||("auto"===i||"scroll"===i)}),i=t.isScrollingOrHidden=function(t,n){var o=e.getComputedStyle(t),r=o.overflow,i=o["overflow-"+n];return"auto"===r||"scroll"===r||"hidden"===r||("auto"===i||"scroll"===i||"hidden"===i)},a=t.hasBiggerChild=function(e,t){return"x"===t?e.scrollWidth>e.clientWidth:e.scrollHeight>e.clientHeight};t.hasScrollBar=function(e,t){return a(e,t)&&r(e,t)},t.getVisibleRect=function(e,t){var r=e,l=t||o(e);for(r=e.parentElement;r;)a(r,"x")&&i(r,"x")&&(l=n(l,r.getBoundingClientRect(),"x")),a(r,"y")&&i(r,"y")&&(l=n(l,r.getBoundingClientRect(),"y")),r=r.parentElement;return l},t.listenScrollParent=function(t,n){var o=[];return setTimeout(function(){for(var i=t;i;)(r(i,"x")||r(i,"y"))&&(i.addEventListener("scroll",n),o.push(i)),i=i.parentElement;e.addEventListener("scroll",n)},10),{dispose:function(){o.forEach(function(e){e.removeEventListener("scroll",n)}),e.removeEventListener("scroll",n)}}},t.hasParent=function(e,t){for(var n=e;n;){if(n===t)return!0;n=n.parentElement}return!1},t.getParent=function(e,t){for(var n=e;n;){if(n.matches(t))return n;n=n.parentElement}return null},t.hasClass=function(e,t){return e.className.split(" ").map(function(e){return e}).indexOf(t)>-1},t.addClass=function(e,t){if(e){var n=e.className.split(" ").filter(function(e){return e});-1===n.indexOf(t)&&(n.push(t),e.className=n.join(" "))}},t.removeClass=function(e,t){if(e){var n=e.className.split(" ").filter(function(e){return e&&e!==t});e.className=n.join(" ")}},t.debounce=function(e,t,n){var o=null;return function(){for(var r=arguments.length,i=Array(r),a=0;a<r;a++)i[a]=arguments[a];o&&clearTimeout(o),n&&!o?e.call.apply(e,[void 0].concat(i)):o=setTimeout(function(){o=null,e.call.apply(e,[void 0].concat(i))},t)}},t.removeChildAt=function(e,t){return e.removeChild(e.children[t])},t.addChildAt=function(e,t,n){n>=e.children.lenght?e.appendChild(t):e.insertBefore(t,e.children[n])},t.isMobile=function(){return"undefined"!=typeof window&&!!(e.navigator.userAgent.match(/Android/i)||e.navigator.userAgent.match(/webOS/i)||e.navigator.userAgent.match(/iPhone/i)||e.navigator.userAgent.match(/iPad/i)||e.navigator.userAgent.match(/iPod/i)||e.navigator.userAgent.match(/BlackBerry/i)||e.navigator.userAgent.match(/Windows Phone/i))},t.clearSelection=function(){e.getSelection?e.getSelection().empty?e.getSelection().empty():e.getSelection().removeAllRanges&&e.getSelection().removeAllRanges():e.document.selection&&e.document.selection.empty()}}).call(this,n(0))},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.domDropHandler=function(t){var n=t.element,i=t.draggables;t.layout,t.options;return function(t,a){var l=t.removedIndex,s=t.addedIndex,u=t.droppedElement,c=null;if(null!==l&&(c=(0,o.removeChildAt)(n,l),i.splice(l,1)),null!==s){var d=e.document.createElement("div");d.className=""+r.wrapperClass,d.appendChild(c.firstElementChild||u),d[r.containersInDraggable]=[],(0,o.addChildAt)(n,d,s),s>=i.length?i.push(d):i.splice(s,0,d)}a&&a(t)}},t.reactDropHandler=function(){return{handler:function(e){e.element,e.draggables,e.layout,e.options;return function(e,t){t&&t(e)}}}};var o=n(2),r=n(1)}).call(this,n(0))},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t,n,l){t[r.extraSizeForInsertion]=0;var s=l,u=function(e){return{get:function(t,n){var o=e[n];return t[o||n]},set:function(t,n,o){requestAnimationFrame(function(){t[e[n]]=e.setters[n]?e.setters[n](o):o})}}}("horizontal"===n?i:a),c={translation:0},d=null;e.addEventListener("resize",function(){m(t)}),setTimeout(function(){g()},10);var f=o.listenScrollParent(t,function(){m(t),d&&d()});function g(){m(t),function(e){var t=e.getBoundingClientRect();c.scaleX=e.offsetWidth?(t.right-t.left)/e.offsetWidth:1,c.scaleY=e.offsetHeight?(t.bottom-t.top)/e.offsetHeight:1}(t)}var p=void 0;function m(e){c.rect=o.getContainerRect(e),c.visibleRect=o.getVisibleRect(e,c.rect)}function v(e){return u.get(e,"size")*u.get(c,"scale")}function h(e){return u.get(e,"dragPosition")}function y(e,t){var o=c.visibleRect,r=o.left,i=o.top,a=o.right,l=o.bottom;l-i<2&&(l=i+30);var s=c.rect;return"vertical"===n?e>s.left&&e<s.right&&t>i&&t<l:e>r&&e<a&&t>s.top&&t<s.bottom}return{getSize:v,getContainerRectangles:function(){return{rect:c.rect,visibleRect:c.visibleRect}},getBeginEndOfDOMRect:function(e){return{begin:u.get(e,"begin"),end:u.get(e,"end")}},getBeginEndOfContainer:function(){var e=u.get(c.rect,"begin")+c.translation,t=u.get(c.rect,"end")+c.translation;return{begin:e,end:t}},getBeginEndOfContainerVisibleRect:function(){var e=u.get(c.visibleRect,"begin")+c.translation,t=u.get(c.visibleRect,"end")+c.translation;return{begin:e,end:t}},getBeginEnd:function(e){var n=function(e){return(u.get(e,"distanceToParent")+(e[r.translationValue]||0))*u.get(c,"scale")}(e)+(u.get(c.rect,"begin")+c.translation)-u.get(t,"scrollValue");return{begin:n,end:n+v(e)*u.get(c,"scale")}},getAxisValue:h,setTranslation:function(e,t){t?u.set(e.style,"translate",t):e.style.removeProperty("transform");e[r.translationValue]=t,e[r.containersInDraggable]&&setTimeout(function(){e[r.containersInDraggable].forEach(function(e){!function e(t){t.layout.invalidateRects();t.onTranslated();t.getChildContainers()&&t.getChildContainers().forEach(function(t){return e(t)})}(e)})},s+20)},getTranslation:function(e){return e[r.translationValue]},setVisibility:function(e,t){void 0!==e[r.visibilityValue]&&e[r.visibilityValue]===t||(t?e.style.removeProperty("visibility"):e.style.visibility="hidden",e[r.visibilityValue]=t)},isVisible:function(e){return void 0===e[r.visibilityValue]||e[r.visibilityValue]},isInVisibleRect:y,dispose:function(){f&&f.dispose();p&&(p.parentNode.removeChild(p),p=null)},getContainerScale:function(){return{scaleX:c.scaleX,scaleY:c.scaleY}},setScrollListener:function(e){d=e},setSize:function(e,t){u.set(e,"setSize",t)},getTopLeftOfElementBegin:function(e){var t=0,o=0;"horizontal"===n?(o=e,t=c.rect.top):(o=c.rect.left,t=e);return{top:t,left:o}},getScrollSize:function(e){return u.get(e,"scrollSize")},getScrollValue:function(e){return u.get(e,"scrollValue")},setScrollValue:function(e,t){return u.set(e,"scrollValue",t)},invalidate:g,invalidateRects:function(){m(t)},getPosition:function(e){return y(e.x,e.y)?h(e):null}}};var o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(n(2)),r=n(1);var i={size:"offsetWidth",distanceToParent:"offsetLeft",translate:"transform",begin:"left",end:"right",dragPosition:"x",scrollSize:"scrollWidth",offsetSize:"offsetWidth",scrollValue:"scrollLeft",scale:"scaleX",setSize:"width",setters:{translate:function(e){return"translate3d("+e+"px, 0, 0)"}}},a={size:"offsetHeight",distanceToParent:"offsetTop",translate:"transform",begin:"top",end:"bottom",dragPosition:"y",scrollSize:"scrollHeight",offsetSize:"offsetHeight",scrollValue:"scrollTop",scale:"scaleY",setSize:"height",setters:{translate:function(e){return"translate3d(0,"+e+"px, 0)"}}}}).call(this,n(0))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(2);var r=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y",n=!1,o=null,r=null,i=null,a=null;return{animate:function(l,s){i=l,a=s,(n=!0)&&function n(){null===o&&(o=requestAnimationFrame(function(l){null===r&&(r=l);var s=l-r;r=l;var u=s/1e3*a;(function(e,t,n){e&&("x"===t?e.scrollLeft+=n:e.scrollTop+=n)})(e,t,u="begin"===i?0-u:u),o=null,n()}))}()},stop:function(){n&&(cancelAnimationFrame(o),n=!1,r=null,o=null)}}};function i(e){var t={element:e,rect:(0,o.getVisibleRect)(e,e.getBoundingClientRect()),descendants:[],invalidate:n,axis:null};function n(){t.rect=(0,o.getVisibleRect)(e,e.getBoundingClientRect()),t.descendants.forEach(function(e){return e.invalidate()})}return e.addEventListener("scroll",function(){n()}),t}function a(e){return Object.assign(e,r(e.element,e.axis))}t.default=function(e){var t,n,r,l=(t=e.map(function(e){return e.element}),n=[],r=null,t.forEach(function(e){var t=e;for(r=null;t;){var a=(0,o.getScrollingAxis)(t);if(a&&!n.some(function(e){return e.element===t})){var l=i(t);r&&l.descendants.push(r),r=l,"xy"===a?(n.push(Object.assign({},l,{axis:"x"})),n.push(Object.assign({},l,{axis:"y"},{descendants:[]}))):n.push(Object.assign({},l,{axis:a}))}t=t.parentElement}}),n).map(a);return function(e){var t=e.draggableInfo,n=e.reset;if(l.length){if(n)return l.forEach(function(e){return e.stop()}),null;l.forEach(function(e){var n=function(e,t){var n=t.rect,o=n.left,r=n.right,i=n.top,a=n.bottom,l=e.x,s=e.y;if(l<o||l>r||s<i||s>a)return null;var u=void 0,c=void 0,d=void 0;return"x"===t.axis?(u=o,c=r,d=l):(u=i,c=a,d=s),c-d<100?{direction:"end",speedFactor:(100-(c-d))/100}:d-u<100?{direction:"begin",speedFactor:(100-(d-u))/100}:void 0}(t.mousePosition,e);n?e.animate(n.direction,1500*n.speedFactor):e.stop()})}}}},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.addStyleToHead=void 0;var o,r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(n(1));function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l={overflow:"hidden",display:"block"},s={height:"100%",display:"inline-block","vertical-align":"top","white-space":"normal"},u=(a(o={},"."+i.containerClass,{position:"relative"}),a(o,"."+i.containerClass+" *",{"box-sizing":"border-box"}),a(o,"."+i.containerClass+".horizontal",{"white-space":"nowrap"}),a(o,"."+i.containerClass+".horizontal > ."+i.wrapperClass,s),a(o,"."+i.containerClass+".vertical > ."+i.wrapperClass,l),a(o,"."+i.wrapperClass,{}),a(o,"."+i.wrapperClass+".horizontal",s),a(o,"."+i.wrapperClass+".vertical",l),a(o,"."+i.wrapperClass+".animated",{transition:"transform ease"}),a(o,"."+i.ghostClass+" *",{"box-sizing":"border-box"}),a(o,"."+i.ghostClass+".animated",{transition:"all ease-in-out"}),a(o,"."+i.disbaleTouchActions+" *",{"touch-actions":"none","-ms-touch-actions":"none"}),a(o,"."+i.noUserSelectClass+" *",{"-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none"}),o);t.addStyleToHead=function(){if("undefined"!=typeof window){var t=e.document.head||e.document.getElementsByTagName("head")[0],n=e.document.createElement("style"),o=function e(t){return Object.keys(t).reduce(function(n,o){var i=t[o];return"object"===(void 0===i?"undefined":r(i))?""+n+o+"{"+e(i)+"}":""+n+o+":"+i+";"},"")}(u);n.type="text/css",n.styleSheet?n.styleSheet.cssText=o:n.appendChild(e.document.createTextNode(o)),t.appendChild(n)}}}).call(this,n(0))},function(e,t,n){"use strict";(function(e){var t;(t=e.Node||e.Element)&&t.prototype&&!t.prototype.matches&&(t.prototype.matches=t.prototype.matchesSelector||t.prototype.mozMatchesSelector||t.prototype.msMatchesSelector||t.prototype.oMatchesSelector||t.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),n=t.length;--n>=0&&t.item(n)!==this;);return n>-1}),function(e){e&&e.prototype&&null==e.prototype.firstElementChild&&Object.defineProperty(e.prototype,"firstElementChild",{get:function(){for(var e,t=this.childNodes,n=0;e=t[n++];)if(1===e.nodeType)return e;return null}})}(e.Node||e.Element),Array.prototype.some||(Array.prototype.some=function(e){if(null==this)throw new TypeError("Array.prototype.some called on null or undefined");if("function"!=typeof e)throw new TypeError;for(var t=Object(this),n=t.length>>>0,o=arguments.length>=2?arguments[1]:void 0,r=0;r<n;r++)if(r in t&&e.call(o,t[r],r,t))return!0;return!1})}).call(this,n(0))},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),n(7);var o,r=u(n(2)),i=u(n(1)),a=n(6),l=n(5),s=(o=l)&&o.__esModule?o:{default:o};function u(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}var c=["mousedown","touchstart"],d=["mousemove","touchmove"],f=["mouseup","touchend"],g=null,p=null,m=null,v=null,h=[],y=!1,b=null,C=null,E=null,x=r.isMobile();function S(){"undefined"!=typeof window&&c.forEach(function(t){e.document.addEventListener(t,w,{passive:!1})})}function O(){return p&&p.parentElement||e.document.body}var D=function(){var t=void 0,n=void 0,o=void 0,r=null,i=1,a=5;function l(e){var o=P(e),r=o.clientX,l=o.clientY;if(n)(Math.abs(t.clientX-r)>a||Math.abs(t.clientY-l)>a)&&c();else if(Math.abs(t.clientX-r)>i||Math.abs(t.clientY-l)>i)return g()}function s(){c()}function u(){c()}function c(){clearTimeout(r),d.forEach(function(t){return e.document.removeEventListener(t,l)},{passive:!1}),f.forEach(function(t){return e.document.removeEventListener(t,s)},{passive:!1}),e.document.removeEventListener("drag",u,{passive:!1})}function g(){clearTimeout(r),c(),o()}return function(i,a,c){t=P(i),o=c,(n=a||(x?200:0))&&(r=setTimeout(g,n)),d.forEach(function(t){return e.document.addEventListener(t,l)},{passive:!1}),f.forEach(function(t){return e.document.addEventListener(t,s)},{passive:!1}),e.document.addEventListener("drag",u,{passive:!1})}}();function w(t){var n=P(t);if(!y&&(p=r.getParent(n.target,"."+i.wrapperClass))){var o=r.getParent(p,"."+i.containerClass),a=h.filter(function(e){return e.element===o})[0],l=a.getOptions().dragHandleSelector,s=a.getOptions().nonDragAreaSelector,u=!0;l&&!r.getParent(n.target,l)&&(u=!1),s&&r.getParent(n.target,s)&&(u=!1),u&&D(n,a.getOptions().dragBeginDelay,function(){r.clearSelection(),A(n),d.forEach(function(t){e.document.addEventListener(t,T,{passive:!1})}),f.forEach(function(t){e.document.addEventListener(t,I,{passive:!1})})})}}function I(){d.forEach(function(t){e.document.removeEventListener(t,T,{passive:!1})}),f.forEach(function(t){e.document.removeEventListener(t,I,{passive:!1})}),C({reset:!0}),v&&function(e){function t(){r.removeClass(m.ghost,"animated"),m.ghost.style.transitionDuration=null,O().removeChild(m.ghost),e()}function n(e,n,o){var i=e.top,a=e.left;r.addClass(m.ghost,"animated"),o&&r.addClass(m.ghost.firstElementChild,o),m.ghost.style.transitionDuration=n+"ms",m.ghost.style.left=a+"px",m.ghost.style.top=i+"px",setTimeout(function(){t()},n+20)}if(v.targetElement){var o=h.filter(function(e){return e.element===v.targetElement})[0];!(d=o.getOptions()).shouldAnimateDrop||d.shouldAnimateDrop(v.container.getOptions(),v.payload)?n(o.getDragResult().shadowBeginEnd.rect,Math.max(150,o.getOptions().animationDuration/2),o.getOptions().dropClass):t()}else{var i=h.filter(function(e){return e===v.container})[0];if("move"===i.getOptions().behaviour&&i.getDragResult()){var a=i.getDragResult(),l=a.removedIndex,s=a.elementSize,u=i.layout;i.getTranslateCalculator({dragResult:{removedIndex:l,addedIndex:l,elementSize:s}});var c=l>0?u.getBeginEnd(i.draggables[l-1]).end:u.getBeginEndOfContainer().begin;n(u.getTopLeftOfElementBegin(c),i.getOptions().animationDuration,i.getOptions().dropClass)}else r.addClass(m.ghost,"animated"),m.ghost.style.transitionDuration=i.getOptions().animationDuration+"ms",m.ghost.style.opacity="0",m.ghost.style.transform="scale(0.90)",setTimeout(function(){t()},i.getOptions().animationDuration)}var d}(function(){r.removeClass(e.document.body,i.disbaleTouchActions),r.removeClass(e.document.body,i.noUserSelectClass),R(!1),(g||[]).forEach(function(e){e.handleDrop(v)}),g=null,p=null,m=null,v=null,y=!1,null,E=null,b=null})}function P(e){return e.touches?e.touches[0]:e}function R(e){h.forEach(function(t){var n=e?t.getOptions().onDragStart:t.getOptions().onDragEnd;if(n){var o={isSource:t===v.container,payload:v.payload};t.isDragRelevant(v.container,v.payload)?o.willAcceptDrop=!0:o.willAcceptDrop=!1,n(o)}})}function A(t,n){y=!0;var o=h.filter(function(e){return p.parentElement===e.element})[0];o.setDraggables(),o,E=o.getOptions().lockAxis?o.getOptions().lockAxis.toLowerCase():null,v=function(e){var t=h.filter(function(t){return e.parentElement===t.element})[0],n=t.draggables.indexOf(e);return{container:t,element:e,elementIndex:n,payload:t.getOptions().getChildPayload?t.getOptions().getChildPayload(n):void 0,targetElement:null,position:{x:0,y:0},groupName:t.getOptions().groupName}}(p),m=function(e,t,n,o){var a=t.x,l=t.y,s=n.getScale(),u=(s.scaleX,s.scaleY,e.getBoundingClientRect()),c=u.left,d=u.top,f=u.right,g=u.bottom,p=c+(f-c)/2,m=d+(g-d)/2,v=e.cloneNode(!0);return v.style.zIndex=1e3,v.style.boxSizing="border-box",v.style.position="fixed",v.style.left=c+"px",v.style.top=d+"px",v.style.width=f-c+"px",v.style.height=g-d+"px",v.style.overflow="visible",v.style.transition=null,v.style.removeProperty("transition"),v.style.pointerEvents="none",setTimeout(function(){n.getOptions().dragClass&&r.addClass(v.firstElementChild,n.getOptions().dragClass)}),r.addClass(v,n.getOptions().orientation),r.addClass(v,i.ghostClass),{ghost:v,centerDelta:{x:p-a,y:m-l},positionDelta:{left:c-a,top:d-l}}}(p,{x:t.clientX,y:t.clientY},v.container),v.position={x:t.clientX+m.centerDelta.x,y:t.clientY+m.centerDelta.y},v.mousePosition={x:t.clientX,y:t.clientY},r.addClass(e.document.body,i.disbaleTouchActions),r.addClass(e.document.body,i.noUserSelectClass),g=h.filter(function(e){return e.isDragRelevant(o,v.payload)}),b=function(e){var t=e;return function(e){var n=!1;t.forEach(function(t){var o=t.handleDrag(e);n|=o.containerBoxChanged||!1,o.containerBoxChanged=!1}),C({draggableInfo:e}),n&&(n=!1,setTimeout(function(){h.forEach(function(e){e.layout.invalidateRects(),e.onTranslated()})},10))}}(g),C=function(e,t){return e.getOptions().autoScrollEnabled?(0,s.default)(t):function(){return null}}(o,g),g.forEach(function(e){return e.prepareDrag(e,g)}),R(!0),b(v),O().appendChild(m.ghost)}function T(e){e.preventDefault();var t=P(e);v?(E?"y"===E?(m.ghost.style.top=t.clientY+m.positionDelta.top+"px",v.position.y=t.clientY+m.centerDelta.y,v.mousePosition.y=t.clientY):"x"===E&&(m.ghost.style.left=t.clientX+m.positionDelta.left+"px",v.position.x=t.clientX+m.centerDelta.x,v.mousePosition.x=t.clientX):(m.ghost.style.left=t.clientX+m.positionDelta.left+"px",m.ghost.style.top=t.clientY+m.positionDelta.top+"px",v.position.x=t.clientX+m.centerDelta.x,v.position.y=t.clientY+m.centerDelta.y,v.mousePosition.x=t.clientX,v.mousePosition.y=t.clientY),b(v)):A(t)}(0,a.addStyleToHead)(),t.default=(S(),{register:function(e){h.push(e)},unregister:function(e){h.splice(h.indexOf(e),1)}})}).call(this,n(0))},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});var o=s(n(8)),r=s(n(4)),i=n(2),a=n(3),l=n(1);function s(e){return e&&e.__esModule?e:{default:e}}var u={groupName:null,behaviour:"move",orientation:"vertical",getChildPayload:null,animationDuration:250,autoScrollEnabled:!0,shouldAcceptDrop:null,shouldAnimateDrop:null};function c(e,t,n){t?((0,i.addClass)(e,l.animationClass),e.style.transitionDuration=n+"ms"):((0,i.removeClass)(e,l.animationClass),e.style.removeProperty("transition-duration"))}function d(e){return e?e[l.containerInstance]:null}function f(t){if(L.wrapChild)return L.wrapChild(t);var n=e.document.createElement("div");return n.className=""+l.wrapperClass,t.parentElement.insertBefore(n,t),n.appendChild(t),n}function g(e){var t=[];return Array.prototype.map.call(e.children,function(n){if(n.nodeType===Node.ELEMENT_NODE){var o=n;(0,i.hasClass)(n,l.wrapperClass)||(o=f(n)),o[l.containersInDraggable]=[],o[l.translationValue]=0,t.push(o)}else e.removeChild(n)}),t}function p(e){var t=e.layout;return function(e,n){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return function e(n,o,r,i){var a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(i<r)return r;if(r===i){var l=t.getBeginEnd(n[r]),s=l.begin,u=l.end;return o>s&&o<=u?a?o<(u+s)/2?r:r+1:r:null}var c=Math.floor((i+r)/2),d=t.getBeginEnd(n[c]),f=d.begin,g=d.end;return o<f?e(n,o,r,c-1,a):o>g?e(n,o,c+1,i,a):a?o<(g+f)/2?c:c+1:c}(e,n,0,e.length-1,o)}}function m(e){var t=e.element,n=e.draggables,o=e.layout,r=e.options,i=function(e){var t=e.element,n=e.draggables,o=e.layout;return e.options,function(){n.forEach(function(e){c(e,!1),o.setTranslation(e,0),o.setVisibility(e,!0),e[l.containersInDraggable]=[]}),t[l.stretcherElementInstance]&&(t[l.stretcherElementInstance].parentNode.removeChild(t[l.stretcherElementInstance]),t[l.stretcherElementInstance]=null)}}({element:t,draggables:n,layout:o,options:r}),s=(L.dropHandler||a.domDropHandler)({element:t,draggables:n,layout:o,options:r});return function(e,t){var n=t.addedIndex,o=t.removedIndex;if(i(),e.targetElement){var a={removedIndex:o,addedIndex:null!==n?null!==o&&o<n?n-1:n:null,payload:e.payload,droppedElement:e.element.firstElementChild};s(a,r.onDrop)}}}function v(e,t){var n=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u;return Object.assign({},u,e)}(t),o=g(e,n.orientation,n.animationDuration);return(0,i.addClass)(e,l.containerClass+" "+n.orientation),{element:e,draggables:o,options:n,layout:(0,r.default)(e,n.orientation,n.animationDuration)}}function h(e,t){var n=function(e,t){for(var n=e.element;n;){var o=d(n.parentElement);if(o&&t.indexOf(o)>-1)return{container:o,draggable:n};n=n.parentElement}return null}(e,t);n&&(n.container.getChildContainers().push(e),e.setParentContainer(n.container),n.draggable[l.containersInDraggable].push(e))}function y(e){e.draggables;var t=e.element,n=e.options,o=null;return function(e){var r=e.draggableInfo,i=(e.dragResult,o);return null==o&&r.container.element===t&&"copy"!==n.behaviour&&(i=o=r.elementIndex),{removedIndex:i}}}function b(e){var t=e.draggables,n=e.layout;return function(e){e.draggableInfo;var o=e.dragResult;null!==o.removedIndex&&n.setVisibility(t[o.removedIndex],!1)}}function C(e){var t=e.element,n=e.layout;return function(e){var o=e.draggableInfo;return{pos:d(t).isPosInChildContainer()?null:n.getPosition(o.position)}}}function E(e){var t=e.element,n=!1;return function(e){e.draggableInfo;var o=e.dragResult;d(t).getParentContainer()&&n!==(null!==o.pos)&&(n=null!==o.pos,d(t).getParentContainer().onChildPositionCaptured(n))}}function x(e){var t=e.layout,n=null;return function(e){var o=e.draggableInfo;return null===e.dragResult.pos?n=null:{elementSize:n=n||t.getSize(o.element)}}}function S(e){var t=e.element;return function(e){var n=e.draggableInfo,o=e.dragResult;!function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t&&n?e.targetElement=t:e.targetElement===t&&(e.targetElement=null)}(n,t,!!o.pos)}}function O(e){e.draggables,e.layout;return function(e){return null!==e.dragResult.pos?{addedIndex:0}:{addedIndex:null}}}function D(e){e.draggables;var t=e.layout,n=null;return function(e){var o=e.dragResult.addedIndex;if(o!==n){n=o;var r=t.getBeginEndOfContainer(),i=r.begin,a=r.end;return{shadowBeginEnd:{rect:t.getTopLeftOfElementBegin(i,a)}}}}}function w(e){var t=T(e);return function(e){var n=e.draggableInfo,o=e.dragResult;return n.invalidateShadow?t({draggableInfo:n,dragResult:o}):null}}function I(e){var t,n,o,r=(n=(t=e).draggables,o=p({layout:t.layout}),function(e){var t=e.dragResult,r=t.shadowBeginEnd,i=t.pos;if(!r){var a=o(n,i,!0);return null!==a?a:n.length}return r.begin+r.beginAdjustment<=i&&r.end>=i?null:i<r.begin+r.beginAdjustment?o(n,i):i>r.end?o(n,i)+1:n.length});return function(e){var t=e.dragResult,n=null;return null!==t.pos&&null===(n=r({dragResult:t}))&&(n=t.addedIndex),{addedIndex:n}}}function P(){var e=null;return function(t){var n=t.dragResult,o=n.addedIndex,r=n.shadowBeginEnd;o!==e&&null!==e&&r&&(r.beginAdjustment=0),e=o}}function R(t){var n=t.element,o=t.draggables,r=t.layout,i=t.options,a=null;return function(t){var s=t.dragResult,u=s.addedIndex,c=s.removedIndex,d=s.elementSize;if(null===c)if(null!==u){if(!a){var f=r.getBeginEndOfContainer();f.end=f.begin+r.getSize(n);var g=r.getScrollSize(n)>r.getSize(n)?f.begin+r.getScrollSize(n)-r.getScrollValue(n):f.end,p=o.length>0?r.getBeginEnd(o[o.length-1]).end-o[o.length-1][l.translationValue]:f.begin;if(p+d>g){(a=e.document.createElement("div")).className=l.stretcherElementClass+" "+i.orientation;var m=d+p-g;return r.setSize(a.style,m+"px"),n.appendChild(a),n[l.stretcherElementInstance]=a,{containerBoxChanged:!0}}}}else if(a){r.setTranslation(a,0);var v=a;return a=null,n.removeChild(v),n[l.stretcherElementInstance]=null,{containerBoxChanged:!0}}}}function A(e){e.element;var t=e.draggables,n=e.layout,o=null,r=null;return function(e){var i=e.dragResult,a=i.addedIndex,l=i.removedIndex,s=i.elementSize;if(a!==o||l!==r){for(var u=0;u<t.length;u++)if(u!==l){var c=t[u],d=0;null!==l&&l<u&&(d-=n.getSize(t[l])),null!==a&&a<=u&&(d+=s),n.setTranslation(c,d)}return o=a,r=l,{addedIndex:a,removedIndex:l}}}}function T(e){var t=e.draggables,n=e.layout,o=null;return function(e){var r=e.draggableInfo,i=e.dragResult,a=i.addedIndex,l=i.removedIndex,s=i.elementSize,u=i.pos,c=i.shadowBeginEnd;if(null!==u){if(null===a||!r.invalidateShadow&&a===o)return null;o&&(o=a);var d=a-1,f=0,g=null,p=null;if(d===l&&d--,d>-1){var m=n.getSize(t[d]);if(p=n.getBeginEnd(t[d]),s<m){var v=(m-s)/2;f=p.end-v}else f=p.end}else p={end:n.getBeginEndOfContainer().begin};var h=1e4,y=a;if(y===l&&y++,y<t.length){var b=n.getSize(t[y]);if(g=n.getBeginEnd(t[y]),s<b){var C=(b-s)/2;h=g.begin+C}else h=g.begin}else g={begin:n.getContainerRectangles().end};return{shadowBeginEnd:{begin:f,end:h,rect:p&&g?n.getTopLeftOfElementBegin(p.end,g.begin):null,beginAdjustment:c?c.beginAdjustment:0}}}return o=null,{shadowBeginEnd:null}}}function _(){var e=null;return function(t){var n=t.dragResult,o=n.pos,r=n.addedIndex,i=n.shadowBeginEnd;t.draggableInfo.invalidateShadow;if(null!==o){if(null!=r&&null===e){if(o<i.begin){var a=o-i.begin-5;i.beginAdjustment=a}e=r}}else e=null}}function z(e){var t=e.options,n=!1;return function(e){var o=!!e.dragResult.pos;if(o!==n){if(n=o,!o)return t.onDragLeave&&t.onDragLeave(),{dragLeft:!0};t.onDragEnter&&t.onDragEnter()}}}function B(e){return"drop-zone"===e.options.behaviour?M(e)(y,b,C,E,x,S,O,D,z):M(e)(y,b,C,E,x,S,w,I,P,R,A,T,_,z)}function M(e){return function(){for(var t=arguments.length,n=Array(t),o=0;o<t;o++)n[o]=arguments[o];var r=n.map(function(t){return t(e)}),i=null;return function(e){return i=r.reduce(function(t,n){return Object.assign(t,n({draggableInfo:e,dragResult:t}))},i||{addedIndex:null,removedIndex:null,elementSize:null,pos:null,shadowBeginEnd:null})}}}function j(e){return function(t){var n=null,o=null,r=v(e,t),a=B(r),s=m(r),u=null,d=!1,p=[];function y(){null!==o&&(o.invalidateShadow=!0,n=a(o),o.invalidateShadow=!1)}function b(e){d=e,u&&(u.onChildPositionCaptured(e),o&&(n=a(o)))}function C(e,t,n){for(var o=g(t,n.orientation,n.animationDuration),r=0;r<o.length;r++)e[r]=o[r];for(var i=0;i<e.length-o.length;i++)e.pop()}return r.layout.setScrollListener(function(){y()}),{element:e,draggables:r.draggables,isDragRelevant:function(e){var t=e.element,n=e.options;return function(e,o){if(n.shouldAcceptDrop)return n.shouldAcceptDrop(e.getOptions(),o);var r=e.getOptions();return"copy"!==n.behaviour&&(0,i.getParent)(t,"."+l.wrapperClass)!==e.element&&(e.element===t||!(!r.groupName||r.groupName!==n.groupName))}}(r),getScale:r.layout.getContainerScale,layout:r.layout,getChildContainers:function(){return p},onChildPositionCaptured:b,dispose:function(e){var t;t=e.element,Array.prototype.map.call(t.children,function(e){if(e.nodeType===Node.ELEMENT_NODE){var n=e;(0,i.hasClass)(e,l.wrapperClass)&&(t.insertBefore(n,f.firstElementChild),t.removeChild(n))}})},prepareDrag:function(e,t){var n=e.element,o=r.draggables,i=e.getOptions();C(o,n,i),e.layout.invalidateRects(),h(e,t),o.forEach(function(e){return c(e,!0,i.animationDuration)})},isPosInChildContainer:function(){return d},handleDrag:function(e){return o=e,(n=a(e)).dragLeft&&"drop-zone"!==r.options.behaviour&&(n.dragLeft=!1,setTimeout(function(){n&&A(r)({dragResult:n})},20)),n},handleDrop:function(e){o=null,b(!1),a=B(r),s(e,n),n=null,u=null,p=[]},getDragResult:function(){return n},getTranslateCalculator:function(){return A(r).apply(void 0,arguments)},setParentContainer:function(e){u=e},getParentContainer:function(){return u},onTranslated:function(){y()},getOptions:function(){return r.options},setDraggables:function(){C(r.draggables,e,r.options)}}}}function L(e,t){var n=j(e)(t);return e[l.containerInstance]=n,o.default.register(n),{dispose:function(){o.default.unregister(n),n.layout.dispose(),n.dispose(n)}}}t.default=L}).call(this,n(0))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dropHandlers=t.constants=void 0;var o,r=n(9),i=(o=r)&&o.__esModule?o:{default:o},a=s(n(1)),l=s(n(3));function s(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}t.default=i.default,t.constants=a,t.dropHandlers=l}])});
{
"name": "smooth-dnd",
"version": "0.4.8",
"version": "0.4.9",
"description": "Drag and Drop library",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -6,594 +6,599 @@ import Mediator from './mediator';

import {
defaultGroupName,
wrapperClass,
animationClass,
stretcherElementClass,
stretcherElementInstance,
translationValue,
containerClass,
containerInstance,
containersInDraggable
defaultGroupName,
wrapperClass,
animationClass,
stretcherElementClass,
stretcherElementInstance,
translationValue,
containerClass,
containerInstance,
containersInDraggable
} from './constants';
const defaultOptions = {
groupName: null,
behaviour: 'move', // move | copy
orientation: 'vertical', // vertical | horizontal
getChildPayload: null,
animationDuration: 250,
autoScrollEnabled: true,
shouldAcceptDrop: null,
shouldAnimateDrop: null
groupName: null,
behaviour: 'move', // move | copy
orientation: 'vertical', // vertical | horizontal
getChildPayload: null,
animationDuration: 250,
autoScrollEnabled: true,
shouldAcceptDrop: null,
shouldAnimateDrop: null
};
function setAnimation(element, add, animationDuration) {
if (add) {
addClass(element, animationClass);
element.style.transitionDuration = animationDuration + 'ms';
} else {
removeClass(element, animationClass);
element.style.removeProperty('transition-duration');
}
if (add) {
addClass(element, animationClass);
element.style.transitionDuration = animationDuration + 'ms';
} else {
removeClass(element, animationClass);
element.style.removeProperty('transition-duration');
}
}
function getContainer(element) {
return element ? element[containerInstance] : null;
return element ? element[containerInstance] : null;
}
function initOptions(props = defaultOptions) {
return Object.assign({}, defaultOptions, props);
return Object.assign({}, defaultOptions, props);
}
function isDragRelevant({ element, options }) {
return function(sourceContainer, payload) {
if (options.shouldAcceptDrop) {
return options.shouldAcceptDrop(sourceContainer.getOptions(), payload)
}
const sourceOptions = sourceContainer.getOptions();
if (options.behaviour === 'copy') return false;
return function(sourceContainer, payload) {
if (options.shouldAcceptDrop) {
return options.shouldAcceptDrop(sourceContainer.getOptions(), payload);
}
const sourceOptions = sourceContainer.getOptions();
if (options.behaviour === 'copy') return false;
const parentWrapper = getParent(element, '.' + wrapperClass);
if (parentWrapper === sourceContainer.element) {
return false;
}
const parentWrapper = getParent(element, '.' + wrapperClass);
if (parentWrapper === sourceContainer.element) {
return false;
}
if (sourceContainer.element === element) return true;
if (sourceOptions.groupName && sourceOptions.groupName === options.groupName) return true;
if (sourceContainer.element === element) return true;
if (sourceOptions.groupName && sourceOptions.groupName === options.groupName) return true;
return false;
};
return false;
};
}
function wrapChild(child) {
if (SmoothDnD.wrapChild) {
return SmoothDnD.wrapChild(child);
}
const div = global.document.createElement('div');
div.className = `${wrapperClass}`;
child.parentElement.insertBefore(div, child);
div.appendChild(child);
return div;
if (SmoothDnD.wrapChild) {
return SmoothDnD.wrapChild(child);
}
const div = global.document.createElement('div');
div.className = `${wrapperClass}`;
child.parentElement.insertBefore(div, child);
div.appendChild(child);
return div;
}
function wrapChildren(element) {
const draggables = []
Array.prototype.map.call(element.children, child => {
if (child.nodeType === Node.ELEMENT_NODE) {
let wrapper = child;
if (!hasClass(child, wrapperClass)) {
wrapper = wrapChild(child);
}
wrapper[containersInDraggable] = [];
wrapper[translationValue] = 0;
draggables.push(wrapper);
} else {
element.removeChild(child);
}
});
return draggables;
const draggables = [];
Array.prototype.map.call(element.children, child => {
if (child.nodeType === Node.ELEMENT_NODE) {
let wrapper = child;
if (!hasClass(child, wrapperClass)) {
wrapper = wrapChild(child);
}
wrapper[containersInDraggable] = [];
wrapper[translationValue] = 0;
draggables.push(wrapper);
} else {
element.removeChild(child);
}
});
return draggables;
}
function unwrapChildren(element) {
Array.prototype.map.call(element.children, child => {
if (child.nodeType === Node.ELEMENT_NODE) {
let wrapper = child;
if (hasClass(child, wrapperClass)) {
element.insertBefore(wrapper, wrapChild.firstElementChild);
element.removeChild(wrapper);
}
}
});
Array.prototype.map.call(element.children, child => {
if (child.nodeType === Node.ELEMENT_NODE) {
let wrapper = child;
if (hasClass(child, wrapperClass)) {
element.insertBefore(wrapper, wrapChild.firstElementChild);
element.removeChild(wrapper);
}
}
});
}
function findDraggebleAtPos({ layout }) {
const find = (draggables, pos, startIndex, endIndex, withRespectToMiddlePoints = false) => {
if (endIndex < startIndex) {
return startIndex;
}
// binary serach draggable
if (startIndex === endIndex) {
let { begin, end } = layout.getBeginEnd(draggables[startIndex]);
// mouse pos is inside draggable
// now decide which index to return
if (pos > begin && pos <= end) {
if (withRespectToMiddlePoints) {
return (pos < ((end + begin) / 2)) ? startIndex : startIndex + 1;
} else {
return startIndex;
}
} else {
return null;
}
} else {
const middleIndex = Math.floor((endIndex + startIndex) / 2);
const { begin, end } = layout.getBeginEnd(draggables[middleIndex]);
if (pos < begin) {
return find(draggables, pos, startIndex, middleIndex - 1, withRespectToMiddlePoints);
} else if (pos > end) {
return find(draggables, pos, middleIndex + 1, endIndex, withRespectToMiddlePoints);
} else {
if (withRespectToMiddlePoints) {
return (pos < ((end + begin) / 2)) ? middleIndex : middleIndex + 1;
} else {
return middleIndex;
}
}
}
};
const find = (draggables, pos, startIndex, endIndex, withRespectToMiddlePoints = false) => {
if (endIndex < startIndex) {
return startIndex;
}
// binary serach draggable
if (startIndex === endIndex) {
let { begin, end } = layout.getBeginEnd(draggables[startIndex]);
// mouse pos is inside draggable
// now decide which index to return
if (pos > begin && pos <= end) {
if (withRespectToMiddlePoints) {
return pos < (end + begin) / 2 ? startIndex : startIndex + 1;
} else {
return startIndex;
}
} else {
return null;
}
} else {
const middleIndex = Math.floor((endIndex + startIndex) / 2);
const { begin, end } = layout.getBeginEnd(draggables[middleIndex]);
if (pos < begin) {
return find(draggables, pos, startIndex, middleIndex - 1, withRespectToMiddlePoints);
} else if (pos > end) {
return find(draggables, pos, middleIndex + 1, endIndex, withRespectToMiddlePoints);
} else {
if (withRespectToMiddlePoints) {
return pos < (end + begin) / 2 ? middleIndex : middleIndex + 1;
} else {
return middleIndex;
}
}
}
};
return (draggables, pos, withRespectToMiddlePoints = false) => {
return find(draggables, pos, 0, draggables.length - 1, withRespectToMiddlePoints);
};
return (draggables, pos, withRespectToMiddlePoints = false) => {
return find(draggables, pos, 0, draggables.length - 1, withRespectToMiddlePoints);
};
}
function resetDraggables({ element, draggables, layout, options }) {
return function() {
draggables.forEach(p => {
setAnimation(p, false);
layout.setTranslation(p, 0);
layout.setVisibility(p, true);
p[containersInDraggable] = [];
});
return function() {
draggables.forEach(p => {
setAnimation(p, false);
layout.setTranslation(p, 0);
layout.setVisibility(p, true);
p[containersInDraggable] = [];
});
if (element[stretcherElementInstance]) {
element[stretcherElementInstance].parentNode.removeChild(element[stretcherElementInstance]);
element[stretcherElementInstance] = null;
}
};
if (element[stretcherElementInstance]) {
element[stretcherElementInstance].parentNode.removeChild(element[stretcherElementInstance]);
element[stretcherElementInstance] = null;
}
};
}
function setTargetContainer(draggableInfo, element, set = true) {
if (element && set) {
draggableInfo.targetElement = element;
} else {
if (draggableInfo.targetElement === element) {
draggableInfo.targetElement = null;
}
}
if (element && set) {
draggableInfo.targetElement = element;
} else {
if (draggableInfo.targetElement === element) {
draggableInfo.targetElement = null;
}
}
}
function handleDrop({ element, draggables, layout, options }) {
const draggablesReset = resetDraggables({ element, draggables, layout, options });
const dropHandler = (SmoothDnD.dropHandler || domDropHandler)(({ element, draggables, layout, options }));
return function(draggableInfo, { addedIndex, removedIndex }) {
draggablesReset();
// if drop zone is valid => complete drag else do nothing everything will be reverted by draggablesReset()
if (draggableInfo.targetElement) {
let actualAddIndex = addedIndex !== null ? ((removedIndex !== null && removedIndex < addedIndex) ? addedIndex - 1 : addedIndex) : null;
const dropHandlerParams = {
removedIndex,
addedIndex: actualAddIndex,
payload: draggableInfo.payload,
droppedElement: draggableInfo.element.firstElementChild
};
dropHandler(dropHandlerParams, options.onDrop);
}
};
const draggablesReset = resetDraggables({ element, draggables, layout, options });
const dropHandler = (SmoothDnD.dropHandler || domDropHandler)({ element, draggables, layout, options });
return function(draggableInfo, { addedIndex, removedIndex }) {
draggablesReset();
// if drop zone is valid => complete drag else do nothing everything will be reverted by draggablesReset()
if (draggableInfo.targetElement) {
let actualAddIndex =
addedIndex !== null ? (removedIndex !== null && removedIndex < addedIndex ? addedIndex - 1 : addedIndex) : null;
const dropHandlerParams = {
removedIndex,
addedIndex: actualAddIndex,
payload: draggableInfo.payload,
droppedElement: draggableInfo.element.firstElementChild
};
dropHandler(dropHandlerParams, options.onDrop);
}
};
}
function getContainerProps(element, initialOptions) {
const options = initOptions(initialOptions);
const draggables = wrapChildren(element, options.orientation, options.animationDuration);
// set flex classes before layout is inited for scroll listener
addClass(element, `${containerClass} ${options.orientation}`);
const layout = layoutManager(element, options.orientation, options.animationDuration);
return {
element,
draggables,
options,
layout
};
const options = initOptions(initialOptions);
const draggables = wrapChildren(element, options.orientation, options.animationDuration);
// set flex classes before layout is inited for scroll listener
addClass(element, `${containerClass} ${options.orientation}`);
const layout = layoutManager(element, options.orientation, options.animationDuration);
return {
element,
draggables,
options,
layout
};
}
function getRelaventParentContainer(container, relevantContainers) {
let current = container.element;
while (current) {
const containerOfParentElement = getContainer(current.parentElement);
if (containerOfParentElement && relevantContainers.indexOf(containerOfParentElement) > -1) {
return {
container: containerOfParentElement,
draggable: current
};
}
current = current.parentElement;
}
let current = container.element;
while (current) {
const containerOfParentElement = getContainer(current.parentElement);
if (containerOfParentElement && relevantContainers.indexOf(containerOfParentElement) > -1) {
return {
container: containerOfParentElement,
draggable: current
};
}
current = current.parentElement;
}
return null;
return null;
}
function registerToParentContainer(container, relevantContainers) {
const parentInfo = getRelaventParentContainer(container, relevantContainers);
if (parentInfo) {
parentInfo.container.getChildContainers().push(container);
container.setParentContainer(parentInfo.container);
//current should be draggable
parentInfo.draggable[containersInDraggable].push(container);
}
const parentInfo = getRelaventParentContainer(container, relevantContainers);
if (parentInfo) {
parentInfo.container.getChildContainers().push(container);
container.setParentContainer(parentInfo.container);
//current should be draggable
parentInfo.draggable[containersInDraggable].push(container);
}
}
function getRemovedItem({ draggables, element, options }) {
let prevRemovedIndex = null;
return ({ draggableInfo, dragResult }) => {
let removedIndex = prevRemovedIndex;
if (prevRemovedIndex == null && draggableInfo.container.element === element && options.behaviour !== 'copy') {
removedIndex = prevRemovedIndex = draggableInfo.elementIndex;
}
let prevRemovedIndex = null;
return ({ draggableInfo, dragResult }) => {
let removedIndex = prevRemovedIndex;
if (prevRemovedIndex == null && draggableInfo.container.element === element && options.behaviour !== 'copy') {
removedIndex = prevRemovedIndex = draggableInfo.elementIndex;
}
return { removedIndex };
};
return { removedIndex };
};
}
function setRemovedItemVisibilty({ draggables, layout }) {
return ({ draggableInfo, dragResult }) => {
if (dragResult.removedIndex !== null) {
layout.setVisibility(draggables[dragResult.removedIndex], false);
}
};
return ({ draggableInfo, dragResult }) => {
if (dragResult.removedIndex !== null) {
layout.setVisibility(draggables[dragResult.removedIndex], false);
}
};
}
function getPosition({ element, layout }) {
return ({ draggableInfo }) => {
return {
pos: !getContainer(element).isPosInChildContainer() ? layout.getPosition(draggableInfo.position) : null
};
};
return ({ draggableInfo }) => {
return {
pos: !getContainer(element).isPosInChildContainer() ? layout.getPosition(draggableInfo.position) : null
};
};
}
function notifyParentOnPositionCapture({ element }) {
let isCaptured = false;
return ({ draggableInfo, dragResult }) => {
if (getContainer(element).getParentContainer() && isCaptured !== (dragResult.pos !== null)) {
isCaptured = dragResult.pos !== null;
getContainer(element).getParentContainer().onChildPositionCaptured(isCaptured);
}
};
let isCaptured = false;
return ({ draggableInfo, dragResult }) => {
if (getContainer(element).getParentContainer() && isCaptured !== (dragResult.pos !== null)) {
isCaptured = dragResult.pos !== null;
getContainer(element)
.getParentContainer()
.onChildPositionCaptured(isCaptured);
}
};
}
function getElementSize({ layout }) {
let elementSize = null;
return ({ draggableInfo, dragResult }) => {
if (dragResult.pos === null) {
return elementSize = null;
} else {
elementSize = elementSize || layout.getSize(draggableInfo.element);
}
return { elementSize };
};
let elementSize = null;
return ({ draggableInfo, dragResult }) => {
if (dragResult.pos === null) {
return (elementSize = null);
} else {
elementSize = elementSize || layout.getSize(draggableInfo.element);
}
return { elementSize };
};
}
function handleTargetContainer({ element }) {
return ({ draggableInfo, dragResult }) => {
setTargetContainer(draggableInfo, element, !!dragResult.pos);
};
return ({ draggableInfo, dragResult }) => {
setTargetContainer(draggableInfo, element, !!dragResult.pos);
};
}
function getDragInsertionIndex({ draggables, layout }) {
const findDraggable = findDraggebleAtPos({ layout });
return ({ dragResult: { shadowBeginEnd, pos } }) => {
if (!shadowBeginEnd) {
const index = findDraggable(draggables, pos, true);
return index !== null ? index : draggables.length;
} else {
if (shadowBeginEnd.begin + shadowBeginEnd.beginAdjustment <= pos && shadowBeginEnd.end >= pos) {
// position inside ghost
return null;
}
}
const findDraggable = findDraggebleAtPos({ layout });
return ({ dragResult: { shadowBeginEnd, pos } }) => {
if (!shadowBeginEnd) {
const index = findDraggable(draggables, pos, true);
return index !== null ? index : draggables.length;
} else {
if (shadowBeginEnd.begin + shadowBeginEnd.beginAdjustment <= pos && shadowBeginEnd.end >= pos) {
// position inside ghost
return null;
}
}
if (pos < shadowBeginEnd.begin + shadowBeginEnd.beginAdjustment) {
return findDraggable(draggables, pos);
} else if (pos > shadowBeginEnd.end) {
return findDraggable(draggables, pos) + 1;
} else {
return draggables.length;
}
};
if (pos < shadowBeginEnd.begin + shadowBeginEnd.beginAdjustment) {
return findDraggable(draggables, pos);
} else if (pos > shadowBeginEnd.end) {
return findDraggable(draggables, pos) + 1;
} else {
return draggables.length;
}
};
}
function getDragInsertionIndexForDropZone({ draggables, layout }) {
return ({ dragResult: { pos } }) => {
return pos !== null ? { addedIndex: 0 } : { addedIndex: null };
}
return ({ dragResult: { pos } }) => {
return pos !== null ? { addedIndex: 0 } : { addedIndex: null };
};
}
function getShadowBeginEndForDropZone({ draggables, layout }) {
let prevAddedIndex = null;
return ({ dragResult: { addedIndex } }) => {
if (addedIndex !== prevAddedIndex) {
prevAddedIndex = addedIndex;
const { begin, end } = layout.getBeginEndOfContainer();
return {
shadowBeginEnd: {
rect: layout.getTopLeftOfElementBegin(begin, end)
}
}
}
}
let prevAddedIndex = null;
return ({ dragResult: { addedIndex } }) => {
if (addedIndex !== prevAddedIndex) {
prevAddedIndex = addedIndex;
const { begin, end } = layout.getBeginEndOfContainer();
return {
shadowBeginEnd: {
rect: layout.getTopLeftOfElementBegin(begin, end)
}
};
}
};
}
function invalidateShadowBeginEndIfNeeded(params) {
const shadowBoundsGetter = getShadowBeginEnd(params);
return ({ draggableInfo, dragResult }) => {
if (draggableInfo.invalidateShadow) {
return shadowBoundsGetter({ draggableInfo, dragResult });
}
return null;
};
const shadowBoundsGetter = getShadowBeginEnd(params);
return ({ draggableInfo, dragResult }) => {
if (draggableInfo.invalidateShadow) {
return shadowBoundsGetter({ draggableInfo, dragResult });
}
return null;
};
}
function getNextAddedIndex(params) {
const getIndexForPos = getDragInsertionIndex(params);
return ({ dragResult }) => {
let index = null;
if (dragResult.pos !== null) {
index = getIndexForPos({ dragResult });
if (index === null) {
index = dragResult.addedIndex;
}
}
return {
addedIndex: index
};
};
const getIndexForPos = getDragInsertionIndex(params);
return ({ dragResult }) => {
let index = null;
if (dragResult.pos !== null) {
index = getIndexForPos({ dragResult });
if (index === null) {
index = dragResult.addedIndex;
}
}
return {
addedIndex: index
};
};
}
function resetShadowAdjustment() {
let lastAddedIndex = null;
return ({ dragResult: { addedIndex, shadowBeginEnd } }) => {
if (addedIndex !== lastAddedIndex && lastAddedIndex !== null && shadowBeginEnd) {
shadowBeginEnd.beginAdjustment = 0;
}
lastAddedIndex = addedIndex;
};
let lastAddedIndex = null;
return ({ dragResult: { addedIndex, shadowBeginEnd } }) => {
if (addedIndex !== lastAddedIndex && lastAddedIndex !== null && shadowBeginEnd) {
shadowBeginEnd.beginAdjustment = 0;
}
lastAddedIndex = addedIndex;
};
}
function handleInsertionSizeChange({ element, draggables, layout, options }) {
let strectherElement = null;
let stretcherElementAdded = false;
return function({ dragResult: { addedIndex, removedIndex, elementSize } }) {
if (removedIndex === null) {
if (addedIndex !== null) {
if (!stretcherElementAdded) {
let strectherElement = null;
return function({ dragResult: { addedIndex, removedIndex, elementSize } }) {
if (removedIndex === null) {
if (addedIndex !== null) {
if (!strectherElement) {
const containerBeginEnd = layout.getBeginEndOfContainer();
const hasScrollBar = layout.getScrollSize(element) > layout.getSize(element);
const containerEnd = hasScrollBar ? (containerBeginEnd.begin + layout.getScrollSize(element) - layout.getScrollValue(element)) : containerBeginEnd.end;
const lastDraggableEnd = draggables.length > 0 ? layout.getBeginEnd(draggables[draggables.length - 1]).end - draggables[draggables.length - 1][translationValue] : containerBeginEnd.begin;
if (lastDraggableEnd + elementSize > containerEnd) {
strectherElement = global.document.createElement('div');
strectherElement.className = stretcherElementClass + ' ' + options.orientation;
const stretcherSize = (elementSize + lastDraggableEnd) - containerEnd;
layout.setSize(strectherElement.style, `${stretcherSize}px`);
element.appendChild(strectherElement);
element[stretcherElementInstance] = strectherElement;
}
stretcherElementAdded = true;
setTimeout(() => {
layout.invalidateRects();
}, 100);
}
} else {
if (strectherElement) {
layout.setTranslation(strectherElement, 0);
let toRemove = strectherElement;
strectherElement = null;
element.removeChild(toRemove);
element[stretcherElementInstance] = null;
}
stretcherElementAdded = false;
setTimeout(() => {
layout.invalidateRects();
}, 100);
}
}
};
containerBeginEnd.end = containerBeginEnd.begin + layout.getSize(element);
const hasScrollBar = layout.getScrollSize(element) > layout.getSize(element);
const containerEnd = hasScrollBar
? containerBeginEnd.begin + layout.getScrollSize(element) - layout.getScrollValue(element)
: containerBeginEnd.end;
const lastDraggableEnd =
draggables.length > 0
? layout.getBeginEnd(draggables[draggables.length - 1]).end -
draggables[draggables.length - 1][translationValue]
: containerBeginEnd.begin;
if (lastDraggableEnd + elementSize > containerEnd) {
strectherElement = global.document.createElement('div');
strectherElement.className = stretcherElementClass + ' ' + options.orientation;
const stretcherSize = elementSize + lastDraggableEnd - containerEnd;
layout.setSize(strectherElement.style, `${stretcherSize}px`);
element.appendChild(strectherElement);
element[stretcherElementInstance] = strectherElement;
return {
containerBoxChanged: true
};
}
}
} else {
if (strectherElement) {
layout.setTranslation(strectherElement, 0);
let toRemove = strectherElement;
strectherElement = null;
element.removeChild(toRemove);
element[stretcherElementInstance] = null;
return {
containerBoxChanged: true
};
}
}
}
};
}
function calculateTranslations({ element, draggables, layout }) {
let prevAddedIndex = null;
let prevRemovedIndex = null;
return function({ dragResult: { addedIndex, removedIndex, elementSize } }) {
if (addedIndex !== prevAddedIndex || removedIndex !== prevRemovedIndex) {
for (let index = 0; index < draggables.length; index++) {
if (index !== removedIndex) {
const draggable = draggables[index];
let translate = 0;
if (removedIndex !== null && removedIndex < index) {
translate -= layout.getSize(draggables[removedIndex]);
}
if (addedIndex !== null && addedIndex <= index) {
translate += elementSize;
}
layout.setTranslation(draggable, translate);
}
}
let prevAddedIndex = null;
let prevRemovedIndex = null;
return function({ dragResult: { addedIndex, removedIndex, elementSize } }) {
if (addedIndex !== prevAddedIndex || removedIndex !== prevRemovedIndex) {
for (let index = 0; index < draggables.length; index++) {
if (index !== removedIndex) {
const draggable = draggables[index];
let translate = 0;
if (removedIndex !== null && removedIndex < index) {
translate -= layout.getSize(draggables[removedIndex]);
}
if (addedIndex !== null && addedIndex <= index) {
translate += elementSize;
}
layout.setTranslation(draggable, translate);
}
}
prevAddedIndex = addedIndex;
prevRemovedIndex = removedIndex;
prevAddedIndex = addedIndex;
prevRemovedIndex = removedIndex;
return { addedIndex, removedIndex };
}
};
return { addedIndex, removedIndex };
}
};
}
function getShadowBeginEnd({ draggables, layout }) {
let prevAddedIndex = null;
return ({ draggableInfo, dragResult }) => {
const { addedIndex, removedIndex, elementSize, pos, shadowBeginEnd } = dragResult;
if (pos !== null) {
if (addedIndex !== null && (draggableInfo.invalidateShadow || addedIndex !== prevAddedIndex)) {
if (prevAddedIndex)
prevAddedIndex = addedIndex;
let beforeIndex = addedIndex - 1;
let begin = 0;
let afterBounds = null;
let beforeBounds = null;
if (beforeIndex === removedIndex) {
beforeIndex--;
}
if (beforeIndex > -1) {
const beforeSize = layout.getSize(draggables[beforeIndex]);
beforeBounds = layout.getBeginEnd(draggables[beforeIndex]);
if (elementSize < beforeSize) {
const threshold = (beforeSize - elementSize) / 2;
begin = beforeBounds.end - threshold;
} else {
begin = beforeBounds.end;
}
} else {
beforeBounds = { end: layout.getBeginEndOfContainer().begin };
}
let prevAddedIndex = null;
return ({ draggableInfo, dragResult }) => {
const { addedIndex, removedIndex, elementSize, pos, shadowBeginEnd } = dragResult;
if (pos !== null) {
if (addedIndex !== null && (draggableInfo.invalidateShadow || addedIndex !== prevAddedIndex)) {
if (prevAddedIndex) prevAddedIndex = addedIndex;
let beforeIndex = addedIndex - 1;
let begin = 0;
let afterBounds = null;
let beforeBounds = null;
if (beforeIndex === removedIndex) {
beforeIndex--;
}
if (beforeIndex > -1) {
const beforeSize = layout.getSize(draggables[beforeIndex]);
beforeBounds = layout.getBeginEnd(draggables[beforeIndex]);
if (elementSize < beforeSize) {
const threshold = (beforeSize - elementSize) / 2;
begin = beforeBounds.end - threshold;
} else {
begin = beforeBounds.end;
}
} else {
beforeBounds = { end: layout.getBeginEndOfContainer().begin };
}
let end = 10000;
let afterIndex = addedIndex;
if (afterIndex === removedIndex) {
afterIndex++;
}
if (afterIndex < draggables.length) {
const afterSize = layout.getSize(draggables[afterIndex]);
afterBounds = layout.getBeginEnd(draggables[afterIndex]);
let end = 10000;
let afterIndex = addedIndex;
if (afterIndex === removedIndex) {
afterIndex++;
}
if (afterIndex < draggables.length) {
const afterSize = layout.getSize(draggables[afterIndex]);
afterBounds = layout.getBeginEnd(draggables[afterIndex]);
if (elementSize < afterSize) {
const threshold = (afterSize - elementSize) / 2;
end = afterBounds.begin + threshold;
} else {
end = afterBounds.begin;
}
} else {
afterBounds = { begin: layout.getContainerRectangles().end };
}
if (elementSize < afterSize) {
const threshold = (afterSize - elementSize) / 2;
end = afterBounds.begin + threshold;
} else {
end = afterBounds.begin;
}
} else {
afterBounds = { begin: layout.getContainerRectangles().end };
}
const shadowRectTopLeft = beforeBounds && afterBounds ? layout.getTopLeftOfElementBegin(beforeBounds.end, afterBounds.begin) : null;
const shadowRectTopLeft =
beforeBounds && afterBounds ? layout.getTopLeftOfElementBegin(beforeBounds.end, afterBounds.begin) : null;
return {
shadowBeginEnd: {
begin,
end,
rect: shadowRectTopLeft,
beginAdjustment: shadowBeginEnd ? shadowBeginEnd.beginAdjustment : 0,
}
};
} else {
return null;
}
} else {
prevAddedIndex = null;
return {
shadowBeginEnd: null
};
}
};
return {
shadowBeginEnd: {
begin,
end,
rect: shadowRectTopLeft,
beginAdjustment: shadowBeginEnd ? shadowBeginEnd.beginAdjustment : 0
}
};
} else {
return null;
}
} else {
prevAddedIndex = null;
return {
shadowBeginEnd: null
};
}
};
}
function handleFirstInsertShadowAdjustment() {
let lastAddedIndex = null;
return ({ dragResult: { pos, addedIndex, shadowBeginEnd }, draggableInfo: { invalidateShadow } }) => {
if (pos !== null) {
if (addedIndex != null && lastAddedIndex === null) {
if (pos < shadowBeginEnd.begin) {
const beginAdjustment = pos - shadowBeginEnd.begin - 5;
shadowBeginEnd.beginAdjustment = beginAdjustment;
}
lastAddedIndex = addedIndex;
}
} else {
lastAddedIndex = null;
}
};
let lastAddedIndex = null;
return ({ dragResult: { pos, addedIndex, shadowBeginEnd }, draggableInfo: { invalidateShadow } }) => {
if (pos !== null) {
if (addedIndex != null && lastAddedIndex === null) {
if (pos < shadowBeginEnd.begin) {
const beginAdjustment = pos - shadowBeginEnd.begin - 5;
shadowBeginEnd.beginAdjustment = beginAdjustment;
}
lastAddedIndex = addedIndex;
}
} else {
lastAddedIndex = null;
}
};
}
function fireDragEnterLeaveEvents({ options }) {
let wasDragIn = false;
return ({ dragResult: { pos } }) => {
const isDragIn = !!pos;
if (isDragIn !== wasDragIn) {
wasDragIn = isDragIn;
if (isDragIn) {
options.onDragEnter && options.onDragEnter();
} else {
options.onDragLeave && options.onDragLeave();
return {
dragLeft: true
}
}
}
}
let wasDragIn = false;
return ({ dragResult: { pos } }) => {
const isDragIn = !!pos;
if (isDragIn !== wasDragIn) {
wasDragIn = isDragIn;
if (isDragIn) {
options.onDragEnter && options.onDragEnter();
} else {
options.onDragLeave && options.onDragLeave();
return {
dragLeft: true
};
}
}
};
}
function getDragHandler(params) {
if (params.options.behaviour === 'drop-zone') {
// sorting is disabled in container, addedIndex will always be 0 if dropped in
return compose(params)(
getRemovedItem,
setRemovedItemVisibilty,
getPosition,
notifyParentOnPositionCapture,
getElementSize,
handleTargetContainer,
getDragInsertionIndexForDropZone,
getShadowBeginEndForDropZone,
fireDragEnterLeaveEvents
)
} else {
return compose(params)(
getRemovedItem,
setRemovedItemVisibilty,
getPosition,
notifyParentOnPositionCapture,
getElementSize,
handleTargetContainer,
invalidateShadowBeginEndIfNeeded,
getNextAddedIndex,
resetShadowAdjustment,
handleInsertionSizeChange,
calculateTranslations,
getShadowBeginEnd,
handleFirstInsertShadowAdjustment,
fireDragEnterLeaveEvents
);
}
if (params.options.behaviour === 'drop-zone') {
// sorting is disabled in container, addedIndex will always be 0 if dropped in
return compose(params)(
getRemovedItem,
setRemovedItemVisibilty,
getPosition,
notifyParentOnPositionCapture,
getElementSize,
handleTargetContainer,
getDragInsertionIndexForDropZone,
getShadowBeginEndForDropZone,
fireDragEnterLeaveEvents
);
} else {
return compose(params)(
getRemovedItem,
setRemovedItemVisibilty,
getPosition,
notifyParentOnPositionCapture,
getElementSize,
handleTargetContainer,
invalidateShadowBeginEndIfNeeded,
getNextAddedIndex,
resetShadowAdjustment,
handleInsertionSizeChange,
calculateTranslations,
getShadowBeginEnd,
handleFirstInsertShadowAdjustment,
fireDragEnterLeaveEvents
);
}
}
function getDefaultDragResult() {
return {
addedIndex: null,
removedIndex: null,
elementSize: null,
pos: null,
shadowBeginEnd: null
};
return {
addedIndex: null,
removedIndex: null,
elementSize: null,
pos: null,
shadowBeginEnd: null
};
}
function compose(params) {
return (...functions) => {
const hydratedFunctions = functions.map(p => p(params));
let result = null;
return (draggableInfo) => {
result = hydratedFunctions.reduce((dragResult, fn) => {
return Object.assign(dragResult, fn({ draggableInfo, dragResult }));
}, result || getDefaultDragResult());
return result;
};
};
return (...functions) => {
const hydratedFunctions = functions.map(p => p(params));
let result = null;
return draggableInfo => {
result = hydratedFunctions.reduce((dragResult, fn) => {
return Object.assign(dragResult, fn({ draggableInfo, dragResult }));
}, result || getDefaultDragResult());
return result;
};
};
}

@@ -603,133 +608,134 @@

function Container(element) {
return function(options) {
let dragResult = null;
let lastDraggableInfo = null;
const props = getContainerProps(element, options);
let dragHandler = getDragHandler(props);
let dropHandler = handleDrop(props);
let parentContainer = null;
let posIsInChildContainer = false;
let childContainers = [];
return function(options) {
let dragResult = null;
let lastDraggableInfo = null;
const props = getContainerProps(element, options);
let dragHandler = getDragHandler(props);
let dropHandler = handleDrop(props);
let parentContainer = null;
let posIsInChildContainer = false;
let childContainers = [];
function processLastDraggableInfo() {
if (lastDraggableInfo !== null) {
lastDraggableInfo.invalidateShadow = true;
dragResult = dragHandler(lastDraggableInfo);
lastDraggableInfo.invalidateShadow = false;
}
}
function processLastDraggableInfo() {
if (lastDraggableInfo !== null) {
lastDraggableInfo.invalidateShadow = true;
dragResult = dragHandler(lastDraggableInfo);
lastDraggableInfo.invalidateShadow = false;
}
}
function onChildPositionCaptured(isCaptured) {
posIsInChildContainer = isCaptured;
if (parentContainer) {
parentContainer.onChildPositionCaptured(isCaptured);
if (lastDraggableInfo) {
dragResult = dragHandler(lastDraggableInfo);
}
}
}
function onChildPositionCaptured(isCaptured) {
posIsInChildContainer = isCaptured;
if (parentContainer) {
parentContainer.onChildPositionCaptured(isCaptured);
if (lastDraggableInfo) {
dragResult = dragHandler(lastDraggableInfo);
}
}
}
function setDraggables(draggables, element, options) {
const newDraggables = wrapChildren(element, options.orientation, options.animationDuration);
for (let i = 0; i < newDraggables.length; i++) {
draggables[i] = newDraggables[i];
}
function setDraggables(draggables, element, options) {
const newDraggables = wrapChildren(element, options.orientation, options.animationDuration);
for (let i = 0; i < newDraggables.length; i++) {
draggables[i] = newDraggables[i];
}
for (let i = 0; i < draggables.length - newDraggables.length; i++) {
draggables.pop();
}
}
for (let i = 0; i < draggables.length - newDraggables.length; i++) {
draggables.pop();
}
}
function prepareDrag(container, relevantContainers) {
const element = container.element;
const draggables = props.draggables;
const options = container.getOptions();
setDraggables(draggables, element, options);
container.layout.invalidateRects();
registerToParentContainer(container, relevantContainers);
draggables.forEach(p => setAnimation(p, true, options.animationDuration));
}
function prepareDrag(container, relevantContainers) {
const element = container.element;
const draggables = props.draggables;
const options = container.getOptions();
setDraggables(draggables, element, options);
container.layout.invalidateRects();
registerToParentContainer(container, relevantContainers);
draggables.forEach(p => setAnimation(p, true, options.animationDuration));
}
props.layout.setScrollListener(function() {
processLastDraggableInfo();
});
props.layout.setScrollListener(function() {
processLastDraggableInfo();
});
function handleDragLeftDeferedTranslation() {
if (dragResult.dragLeft && props.options.behaviour !== 'drop-zone') {
dragResult.dragLeft = false;
setTimeout(() => {
if (dragResult)
calculateTranslations(props)({ dragResult });
}, 20);
}
}
function handleDragLeftDeferedTranslation() {
if (dragResult.dragLeft && props.options.behaviour !== 'drop-zone') {
dragResult.dragLeft = false;
setTimeout(() => {
if (dragResult) calculateTranslations(props)({ dragResult });
}, 20);
}
}
function dispose(container) {
unwrapChildren(container.element);
}
function dispose(container) {
unwrapChildren(container.element);
}
return {
element,
draggables: props.draggables,
isDragRelevant: isDragRelevant(props),
getScale: props.layout.getContainerScale,
layout: props.layout,
getChildContainers: () => childContainers,
onChildPositionCaptured,
dispose,
prepareDrag,
isPosInChildContainer: () => posIsInChildContainer,
handleDrag: function(draggableInfo) {
lastDraggableInfo = draggableInfo;
dragResult = dragHandler(draggableInfo);
handleDragLeftDeferedTranslation();
return dragResult;
},
handleDrop: function(draggableInfo) {
lastDraggableInfo = null;
onChildPositionCaptured(false);
dragHandler = getDragHandler(props);
dropHandler(draggableInfo, dragResult);
dragResult = null;
parentContainer = null;
childContainers = [];
},
getDragResult: function() {
return dragResult;
},
getTranslateCalculator: function(...params) {
return calculateTranslations(props)(...params);
},
setParentContainer: (e) => { parentContainer = e; },
getParentContainer: () => parentContainer,
onTranslated: () => {
processLastDraggableInfo();
},
getOptions: () => props.options,
setDraggables: () => {
setDraggables(props.draggables, element, props.options);
}
};
};
return {
element,
draggables: props.draggables,
isDragRelevant: isDragRelevant(props),
getScale: props.layout.getContainerScale,
layout: props.layout,
getChildContainers: () => childContainers,
onChildPositionCaptured,
dispose,
prepareDrag,
isPosInChildContainer: () => posIsInChildContainer,
handleDrag: function(draggableInfo) {
lastDraggableInfo = draggableInfo;
dragResult = dragHandler(draggableInfo);
handleDragLeftDeferedTranslation();
return dragResult;
},
handleDrop: function(draggableInfo) {
lastDraggableInfo = null;
onChildPositionCaptured(false);
dragHandler = getDragHandler(props);
dropHandler(draggableInfo, dragResult);
dragResult = null;
parentContainer = null;
childContainers = [];
},
getDragResult: function() {
return dragResult;
},
getTranslateCalculator: function(...params) {
return calculateTranslations(props)(...params);
},
setParentContainer: e => {
parentContainer = e;
},
getParentContainer: () => parentContainer,
onTranslated: () => {
processLastDraggableInfo();
},
getOptions: () => props.options,
setDraggables: () => {
setDraggables(props.draggables, element, props.options);
}
};
};
}
const options = {
behaviour: 'move',
groupName: 'bla bla', // if not defined => container will not interfere with other containers
orientation: 'vertical',
dragHandleSelector: null,
nonDragAreaSelector: 'some selector',
dragBeginDelay: 0,
animationDuration: 180,
autoScrollEnabled: true,
lockAxis: true,
dragClass: null,
dropClass: null,
onDragStart: (index, payload) => { },
onDrop: ({ removedIndex, addedIndex, payload, element }) => { },
getChildPayload: (index) => null,
shouldAnimateDrop: (sourceContainerOptions, payload) => true,
shouldAcceptDrop: (sourceContainerOptions, payload) => true,
onDragEnter: () => { },
onDragLeave: () => { },
behaviour: 'move',
groupName: 'bla bla', // if not defined => container will not interfere with other containers
orientation: 'vertical',
dragHandleSelector: null,
nonDragAreaSelector: 'some selector',
dragBeginDelay: 0,
animationDuration: 180,
autoScrollEnabled: true,
lockAxis: true,
dragClass: null,
dropClass: null,
onDragStart: (index, payload) => {},
onDrop: ({ removedIndex, addedIndex, payload, element }) => {},
getChildPayload: index => null,
shouldAnimateDrop: (sourceContainerOptions, payload) => true,
shouldAcceptDrop: (sourceContainerOptions, payload) => true,
onDragEnter: () => {},
onDragLeave: () => {}
};

@@ -739,15 +745,15 @@

function SmoothDnD(element, options) {
const containerIniter = Container(element);
const container = containerIniter(options);
element[containerInstance] = container;
Mediator.register(container);
return {
dispose: function() {
Mediator.unregister(container);
container.layout.dispose();
container.dispose(container);
}
};
const containerIniter = Container(element);
const container = containerIniter(options);
element[containerInstance] = container;
Mediator.register(container);
return {
dispose: function() {
Mediator.unregister(container);
container.layout.dispose();
container.dispose(container);
}
};
}
export default SmoothDnD;

@@ -29,380 +29,429 @@ import './polyfills';

function listenEvents() {
if (typeof (window) !== 'undefined') {
addGrabListeners();
}
if (typeof window !== 'undefined') {
addGrabListeners();
}
}
function addGrabListeners() {
grabEvents.forEach(e => {
global.document.addEventListener(e, onMouseDown, { passive: false });
});
grabEvents.forEach(e => {
global.document.addEventListener(e, onMouseDown, { passive: false });
});
}
function addMoveListeners() {
moveEvents.forEach(e => {
global.document.addEventListener(e, onMouseMove, { passive: false });
});
moveEvents.forEach(e => {
global.document.addEventListener(e, onMouseMove, { passive: false });
});
}
function removeMoveListeners() {
moveEvents.forEach(e => {
global.document.removeEventListener(e, onMouseMove, { passive: false });
});
moveEvents.forEach(e => {
global.document.removeEventListener(e, onMouseMove, { passive: false });
});
}
function addReleaseListeners() {
releaseEvents.forEach(e => {
global.document.addEventListener(e, onMouseUp, { passive: false });
});
releaseEvents.forEach(e => {
global.document.addEventListener(e, onMouseUp, { passive: false });
});
}
function removeReleaseListeners() {
releaseEvents.forEach(e => {
global.document.removeEventListener(e, onMouseUp, { passive: false });
});
releaseEvents.forEach(e => {
global.document.removeEventListener(e, onMouseUp, { passive: false });
});
}
function getGhostParent() {
if (grabbedElement) {
return grabbedElement.parentElement || global.document.body;
} else {
return global.document.body;
}
if (grabbedElement) {
return grabbedElement.parentElement || global.document.body;
} else {
return global.document.body;
}
}
function getGhostElement(wrapperElement, { x, y }, container, cursor) {
const { scaleX = 1, scaleY = 1 } = container.getScale();
const { left, top, right, bottom } = wrapperElement.getBoundingClientRect();
const midX = left + ((right - left) / 2);
const midY = top + ((bottom - top) / 2);
const ghost = wrapperElement.cloneNode(true);
ghost.style.zIndex = 1000;
ghost.style.boxSizing = 'border-box';
ghost.style.position = 'fixed';
ghost.style.left = left + 'px';
ghost.style.top = top + 'px';
ghost.style.width = right - left + 'px';
ghost.style.height = bottom - top + 'px';
ghost.style.overflow = 'visible';
ghost.style.transition = null;
ghost.style.removeProperty("transition");
ghost.style.pointerEvents = 'none';
// ghost.style.cursor = cursor;
setTimeout(() => {
if (container.getOptions().dragClass) {
Utils.addClass(ghost.firstElementChild, container.getOptions().dragClass);
}
});
Utils.addClass(ghost, container.getOptions().orientation);
Utils.addClass(ghost, constants.ghostClass);
const { scaleX = 1, scaleY = 1 } = container.getScale();
const { left, top, right, bottom } = wrapperElement.getBoundingClientRect();
const midX = left + (right - left) / 2;
const midY = top + (bottom - top) / 2;
const ghost = wrapperElement.cloneNode(true);
ghost.style.zIndex = 1000;
ghost.style.boxSizing = 'border-box';
ghost.style.position = 'fixed';
ghost.style.left = left + 'px';
ghost.style.top = top + 'px';
ghost.style.width = right - left + 'px';
ghost.style.height = bottom - top + 'px';
ghost.style.overflow = 'visible';
ghost.style.transition = null;
ghost.style.removeProperty('transition');
ghost.style.pointerEvents = 'none';
// ghost.style.cursor = cursor;
setTimeout(() => {
if (container.getOptions().dragClass) {
Utils.addClass(ghost.firstElementChild, container.getOptions().dragClass);
}
});
Utils.addClass(ghost, container.getOptions().orientation);
Utils.addClass(ghost, constants.ghostClass);
return {
ghost: ghost,
centerDelta: { x: midX - x, y: midY - y },
positionDelta: { left: left - x, top: top - y }
};
return {
ghost: ghost,
centerDelta: { x: midX - x, y: midY - y },
positionDelta: { left: left - x, top: top - y }
};
}
function getDraggableInfo(draggableElement) {
const container = containers.filter(p => draggableElement.parentElement === p.element)[0];
const draggableIndex = container.draggables.indexOf(draggableElement);
return {
container,
element: draggableElement,
elementIndex: draggableIndex,
payload: container.getOptions().getChildPayload ? container.getOptions().getChildPayload(draggableIndex) : undefined,
targetElement: null,
position: { x: 0, y: 0 },
groupName: container.getOptions().groupName
};
const container = containers.filter(p => draggableElement.parentElement === p.element)[0];
const draggableIndex = container.draggables.indexOf(draggableElement);
return {
container,
element: draggableElement,
elementIndex: draggableIndex,
payload: container.getOptions().getChildPayload
? container.getOptions().getChildPayload(draggableIndex)
: undefined,
targetElement: null,
position: { x: 0, y: 0 },
groupName: container.getOptions().groupName
};
}
function handleDropAnimation(callback) {
function endDrop() {
Utils.removeClass(ghostInfo.ghost, 'animated');
ghostInfo.ghost.style.transitionDuration = null;
getGhostParent().removeChild(ghostInfo.ghost);
callback();
}
function endDrop() {
Utils.removeClass(ghostInfo.ghost, 'animated');
ghostInfo.ghost.style.transitionDuration = null;
getGhostParent().removeChild(ghostInfo.ghost);
callback();
}
function animateGhostToPosition({ top, left }, duration, dropClass) {
Utils.addClass(ghostInfo.ghost, 'animated');
if (dropClass) {
Utils.addClass(ghostInfo.ghost.firstElementChild, dropClass);
}
ghostInfo.ghost.style.transitionDuration = duration + 'ms';
ghostInfo.ghost.style.left = left + 'px';
ghostInfo.ghost.style.top = top + 'px';
setTimeout(function() {
endDrop();
}, duration + 20);
}
function animateGhostToPosition({ top, left }, duration, dropClass) {
Utils.addClass(ghostInfo.ghost, 'animated');
if (dropClass) {
Utils.addClass(ghostInfo.ghost.firstElementChild, dropClass);
}
ghostInfo.ghost.style.transitionDuration = duration + 'ms';
ghostInfo.ghost.style.left = left + 'px';
ghostInfo.ghost.style.top = top + 'px';
setTimeout(function() {
endDrop();
}, duration + 20);
}
function shouldAnimateDrop(options) {
return options.shouldAnimateDrop ? options.shouldAnimateDrop(
draggableInfo.container.getOptions(),
draggableInfo.payload
) : true;
}
function shouldAnimateDrop(options) {
return options.shouldAnimateDrop
? options.shouldAnimateDrop(draggableInfo.container.getOptions(), draggableInfo.payload)
: true;
}
if (draggableInfo.targetElement) {
const container = containers.filter(p => p.element === draggableInfo.targetElement)[0];
if (shouldAnimateDrop(container.getOptions())) {
const dragResult = container.getDragResult();
animateGhostToPosition(dragResult.shadowBeginEnd.rect, Math.max(150, container.getOptions().animationDuration / 2), container.getOptions().dropClass);
} else {
endDrop();
}
} else {
const container = containers.filter(p => p === draggableInfo.container)[0];
if (container.getOptions().behaviour === 'move' && container.getDragResult()) {
const { removedIndex, elementSize } = container.getDragResult();
const layout = container.layout;
// drag ghost to back
container.getTranslateCalculator({
dragResult: {
removedIndex,
addedIndex: removedIndex,
elementSize
}
});
const prevDraggableEnd = removedIndex > 0 ? layout.getBeginEnd(container.draggables[removedIndex - 1]).end : layout.getBeginEndOfContainer().begin;
animateGhostToPosition(layout.getTopLeftOfElementBegin(prevDraggableEnd), container.getOptions().animationDuration, container.getOptions().dropClass);
} else {
Utils.addClass(ghostInfo.ghost, 'animated');
ghostInfo.ghost.style.transitionDuration = container.getOptions().animationDuration + 'ms';
ghostInfo.ghost.style.opacity = '0';
ghostInfo.ghost.style.transform = 'scale(0.90)';
setTimeout(function() {
endDrop();
}, container.getOptions().animationDuration);
}
}
if (draggableInfo.targetElement) {
const container = containers.filter(p => p.element === draggableInfo.targetElement)[0];
if (shouldAnimateDrop(container.getOptions())) {
const dragResult = container.getDragResult();
animateGhostToPosition(
dragResult.shadowBeginEnd.rect,
Math.max(150, container.getOptions().animationDuration / 2),
container.getOptions().dropClass
);
} else {
endDrop();
}
} else {
const container = containers.filter(p => p === draggableInfo.container)[0];
if (container.getOptions().behaviour === 'move' && container.getDragResult()) {
const { removedIndex, elementSize } = container.getDragResult();
const layout = container.layout;
// drag ghost to back
container.getTranslateCalculator({
dragResult: {
removedIndex,
addedIndex: removedIndex,
elementSize
}
});
const prevDraggableEnd =
removedIndex > 0
? layout.getBeginEnd(container.draggables[removedIndex - 1]).end
: layout.getBeginEndOfContainer().begin;
animateGhostToPosition(
layout.getTopLeftOfElementBegin(prevDraggableEnd),
container.getOptions().animationDuration,
container.getOptions().dropClass
);
} else {
Utils.addClass(ghostInfo.ghost, 'animated');
ghostInfo.ghost.style.transitionDuration = container.getOptions().animationDuration + 'ms';
ghostInfo.ghost.style.opacity = '0';
ghostInfo.ghost.style.transform = 'scale(0.90)';
setTimeout(function() {
endDrop();
}, container.getOptions().animationDuration);
}
}
}
const handleDragStartConditions = (function handleDragStartConditions() {
let startEvent;
let delay;
let clb;
let timer = null;
const moveThreshold = 1;
const maxMoveInDelay = 5;
let startEvent;
let delay;
let clb;
let timer = null;
const moveThreshold = 1;
const maxMoveInDelay = 5;
function onMove(event) {
const { clientX: currentX, clientY: currentY } = getPointerEvent(event);
if (!delay) {
if (Math.abs(startEvent.clientX - currentX) > moveThreshold || Math.abs(startEvent.clientY - currentY) > moveThreshold) {
return callCallback();
}
} else {
if (Math.abs(startEvent.clientX - currentX) > maxMoveInDelay || Math.abs(startEvent.clientY - currentY) > maxMoveInDelay) {
deregisterEvent();
}
}
}
function onMove(event) {
const { clientX: currentX, clientY: currentY } = getPointerEvent(event);
if (!delay) {
if (
Math.abs(startEvent.clientX - currentX) > moveThreshold ||
Math.abs(startEvent.clientY - currentY) > moveThreshold
) {
return callCallback();
}
} else {
if (
Math.abs(startEvent.clientX - currentX) > maxMoveInDelay ||
Math.abs(startEvent.clientY - currentY) > maxMoveInDelay
) {
deregisterEvent();
}
}
}
function onUp() { deregisterEvent(); }
function onHTMLDrag() { deregisterEvent(); }
function onUp() {
deregisterEvent();
}
function onHTMLDrag() {
deregisterEvent();
}
function registerEvents() {
if (delay) {
timer = setTimeout(callCallback, delay);
}
function registerEvents() {
if (delay) {
timer = setTimeout(callCallback, delay);
}
moveEvents.forEach(e => global.document.addEventListener(e, onMove), { passive: false });
releaseEvents.forEach(e => global.document.addEventListener(e, onUp), { passive: false });
global.document.addEventListener("drag", onHTMLDrag, {
moveEvents.forEach(e => global.document.addEventListener(e, onMove), {
passive: false
});
}
releaseEvents.forEach(e => global.document.addEventListener(e, onUp), {
passive: false
});
global.document.addEventListener('drag', onHTMLDrag, {
passive: false
});
}
function deregisterEvent() {
clearTimeout(timer);
moveEvents.forEach(e => global.document.removeEventListener(e, onMove), { passive: false });
releaseEvents.forEach(e => global.document.removeEventListener(e, onUp), { passive: false });
global.document.removeEventListener("drag", onHTMLDrag, {
function deregisterEvent() {
clearTimeout(timer);
moveEvents.forEach(e => global.document.removeEventListener(e, onMove), {
passive: false
});
}
releaseEvents.forEach(e => global.document.removeEventListener(e, onUp), {
passive: false
});
global.document.removeEventListener('drag', onHTMLDrag, {
passive: false
});
}
function callCallback() {
clearTimeout(timer);
deregisterEvent();
clb();
}
function callCallback() {
clearTimeout(timer);
deregisterEvent();
clb();
}
return function(_startEvent, _delay, _clb) {
startEvent = getPointerEvent(_startEvent);
delay = _delay || (isMobile ? 200 : 0);
clb = _clb;
return function(_startEvent, _delay, _clb) {
startEvent = getPointerEvent(_startEvent);
delay = _delay || (isMobile ? 200 : 0);
clb = _clb;
registerEvents();
};
registerEvents();
};
})();
function onMouseDown(event) {
const e = getPointerEvent(event);
if (!isDragging) {
grabbedElement = Utils.getParent(e.target, '.' + constants.wrapperClass);
if (grabbedElement) {
const containerElement = Utils.getParent(grabbedElement, '.' + constants.containerClass);
const container = containers.filter(p => p.element === containerElement)[0];
const dragHandleSelector = container.getOptions().dragHandleSelector;
const nonDragAreaSelector = container.getOptions().nonDragAreaSelector;
const e = getPointerEvent(event);
if (!isDragging) {
grabbedElement = Utils.getParent(e.target, '.' + constants.wrapperClass);
if (grabbedElement) {
const containerElement = Utils.getParent(grabbedElement, '.' + constants.containerClass);
const container = containers.filter(p => p.element === containerElement)[0];
const dragHandleSelector = container.getOptions().dragHandleSelector;
const nonDragAreaSelector = container.getOptions().nonDragAreaSelector;
let startDrag = true;
if (dragHandleSelector && !Utils.getParent(e.target, dragHandleSelector)) {
startDrag = false;
}
let startDrag = true;
if (dragHandleSelector && !Utils.getParent(e.target, dragHandleSelector)) {
startDrag = false;
}
if (nonDragAreaSelector && Utils.getParent(e.target, nonDragAreaSelector)) {
startDrag = false;
}
if (nonDragAreaSelector && Utils.getParent(e.target, nonDragAreaSelector)) {
startDrag = false;
}
if (startDrag) {
handleDragStartConditions(e, container.getOptions().dragBeginDelay, () => {
Utils.clearSelection();
initiateDrag(e);
addMoveListeners();
addReleaseListeners();
});
}
}
}
if (startDrag) {
handleDragStartConditions(e, container.getOptions().dragBeginDelay, () => {
Utils.clearSelection();
initiateDrag(e);
addMoveListeners();
addReleaseListeners();
});
}
}
}
}
function onMouseUp() {
removeMoveListeners();
removeReleaseListeners();
handleScroll({ reset: true });
if (draggableInfo) {
handleDropAnimation(() => {
Utils.removeClass(global.document.body, constants.disbaleTouchActions);
Utils.removeClass(global.document.body, constants.noUserSelectClass);
fireOnDragStartEnd(false);
(dragListeningContainers || []).forEach(p => {
p.handleDrop(draggableInfo);
});
dragListeningContainers = null;
grabbedElement = null;
ghostInfo = null;
draggableInfo = null;
isDragging = false;
sourceContainer = null;
sourceContainerLockAxis = null;
handleDrag = null;
});
}
removeMoveListeners();
removeReleaseListeners();
handleScroll({ reset: true });
if (draggableInfo) {
handleDropAnimation(() => {
Utils.removeClass(global.document.body, constants.disbaleTouchActions);
Utils.removeClass(global.document.body, constants.noUserSelectClass);
fireOnDragStartEnd(false);
(dragListeningContainers || []).forEach(p => {
p.handleDrop(draggableInfo);
});
dragListeningContainers = null;
grabbedElement = null;
ghostInfo = null;
draggableInfo = null;
isDragging = false;
sourceContainer = null;
sourceContainerLockAxis = null;
handleDrag = null;
});
}
}
function getPointerEvent(e) {
return e.touches ? e.touches[0] : e;
return e.touches ? e.touches[0] : e;
}
function dragHandler(dragListeningContainers) {
let containers = dragListeningContainers;
return function(draggableInfo) {
containers.forEach(p => p.handleDrag(draggableInfo));
handleScroll({draggableInfo});
}
let targetContainers = dragListeningContainers;
return function(draggableInfo) {
let containerBoxChanged = false;
targetContainers.forEach(p => {
const dragResult = p.handleDrag(draggableInfo);
containerBoxChanged |= dragResult.containerBoxChanged || false;
dragResult.containerBoxChanged = false;
});
handleScroll({ draggableInfo });
if (containerBoxChanged) {
containerBoxChanged = false;
setTimeout(() => {
containers.forEach(p => {
p.layout.invalidateRects();
p.onTranslated();
});
}, 10);
}
};
}
function getScrollHandler(container, dragListeningContainers) {
if (container.getOptions().autoScrollEnabled) {
return dragScroller(dragListeningContainers);
} else {
return () => null;
}
if (container.getOptions().autoScrollEnabled) {
return dragScroller(dragListeningContainers);
} else {
return () => null;
}
}
function fireOnDragStartEnd(isStart) {
containers.forEach(p => {
const fn = isStart ? p.getOptions().onDragStart : p.getOptions().onDragEnd;
if (fn) {
const options = {
isSource: p === draggableInfo.container,
payload: draggableInfo.payload
};
if (p.isDragRelevant(draggableInfo.container, draggableInfo.payload)) {
options.willAcceptDrop = true;
} else {
options.willAcceptDrop = false;
}
fn(options);
}
});
containers.forEach(p => {
const fn = isStart ? p.getOptions().onDragStart : p.getOptions().onDragEnd;
if (fn) {
const options = {
isSource: p === draggableInfo.container,
payload: draggableInfo.payload
};
if (p.isDragRelevant(draggableInfo.container, draggableInfo.payload)) {
options.willAcceptDrop = true;
} else {
options.willAcceptDrop = false;
}
fn(options);
}
});
}
function initiateDrag(position, cursor) {
isDragging = true;
const container = containers.filter(p => grabbedElement.parentElement === p.element)[0];
container.setDraggables();
sourceContainer = container;
sourceContainerLockAxis = container.getOptions().lockAxis ? container.getOptions().lockAxis.toLowerCase() : null;
isDragging = true;
const container = containers.filter(p => grabbedElement.parentElement === p.element)[0];
container.setDraggables();
sourceContainer = container;
sourceContainerLockAxis = container.getOptions().lockAxis ? container.getOptions().lockAxis.toLowerCase() : null;
draggableInfo = getDraggableInfo(grabbedElement);
ghostInfo = getGhostElement(grabbedElement, { x: position.clientX, y: position.clientY }, draggableInfo.container, cursor);
draggableInfo.position = {
x: position.clientX + ghostInfo.centerDelta.x,
y: position.clientY + ghostInfo.centerDelta.y
};
draggableInfo.mousePosition = {
x: position.clientX,
y: position.clientY
}
draggableInfo = getDraggableInfo(grabbedElement);
ghostInfo = getGhostElement(
grabbedElement,
{ x: position.clientX, y: position.clientY },
draggableInfo.container,
cursor
);
draggableInfo.position = {
x: position.clientX + ghostInfo.centerDelta.x,
y: position.clientY + ghostInfo.centerDelta.y
};
draggableInfo.mousePosition = {
x: position.clientX,
y: position.clientY
};
Utils.addClass(global.document.body, constants.disbaleTouchActions);
Utils.addClass(global.document.body, constants.noUserSelectClass);
dragListeningContainers = containers.filter(p => p.isDragRelevant(container, draggableInfo.payload));
handleDrag = dragHandler(dragListeningContainers);
handleScroll = getScrollHandler(container, dragListeningContainers);
dragListeningContainers.forEach(p => p.prepareDrag(p, dragListeningContainers));
fireOnDragStartEnd(true);
handleDrag(draggableInfo);
getGhostParent().appendChild(ghostInfo.ghost);
Utils.addClass(global.document.body, constants.disbaleTouchActions);
Utils.addClass(global.document.body, constants.noUserSelectClass);
dragListeningContainers = containers.filter(p => p.isDragRelevant(container, draggableInfo.payload));
handleDrag = dragHandler(dragListeningContainers);
handleScroll = getScrollHandler(container, dragListeningContainers);
dragListeningContainers.forEach(p => p.prepareDrag(p, dragListeningContainers));
fireOnDragStartEnd(true);
handleDrag(draggableInfo);
getGhostParent().appendChild(ghostInfo.ghost);
}
function onMouseMove(event) {
event.preventDefault();
const e = getPointerEvent(event);
if (!draggableInfo) {
initiateDrag(e);
} else {
// just update ghost position && draggableInfo position
if (sourceContainerLockAxis) {
if (sourceContainerLockAxis === 'y') {
ghostInfo.ghost.style.top = `${e.clientY + ghostInfo.positionDelta.top}px`;
draggableInfo.position.y = e.clientY + ghostInfo.centerDelta.y;
draggableInfo.mousePosition.y = e.clientY;
} else if (sourceContainerLockAxis === 'x') {
ghostInfo.ghost.style.left = `${e.clientX + ghostInfo.positionDelta.left}px`;
draggableInfo.position.x = e.clientX + ghostInfo.centerDelta.x;
draggableInfo.mousePosition.x = e.clientX;
}
} else {
ghostInfo.ghost.style.left = `${e.clientX + ghostInfo.positionDelta.left}px`;
ghostInfo.ghost.style.top = `${e.clientY + ghostInfo.positionDelta.top}px`;
draggableInfo.position.x = e.clientX + ghostInfo.centerDelta.x;
draggableInfo.position.y = e.clientY + ghostInfo.centerDelta.y;
draggableInfo.mousePosition.x = e.clientX;
draggableInfo.mousePosition.y = e.clientY;
}
event.preventDefault();
const e = getPointerEvent(event);
if (!draggableInfo) {
initiateDrag(e);
} else {
// just update ghost position && draggableInfo position
if (sourceContainerLockAxis) {
if (sourceContainerLockAxis === 'y') {
ghostInfo.ghost.style.top = `${e.clientY + ghostInfo.positionDelta.top}px`;
draggableInfo.position.y = e.clientY + ghostInfo.centerDelta.y;
draggableInfo.mousePosition.y = e.clientY;
} else if (sourceContainerLockAxis === 'x') {
ghostInfo.ghost.style.left = `${e.clientX + ghostInfo.positionDelta.left}px`;
draggableInfo.position.x = e.clientX + ghostInfo.centerDelta.x;
draggableInfo.mousePosition.x = e.clientX;
}
} else {
ghostInfo.ghost.style.left = `${e.clientX + ghostInfo.positionDelta.left}px`;
ghostInfo.ghost.style.top = `${e.clientY + ghostInfo.positionDelta.top}px`;
draggableInfo.position.x = e.clientX + ghostInfo.centerDelta.x;
draggableInfo.position.y = e.clientY + ghostInfo.centerDelta.y;
draggableInfo.mousePosition.x = e.clientX;
draggableInfo.mousePosition.y = e.clientY;
}
handleDrag(draggableInfo);
}
handleDrag(draggableInfo);
}
}
function Mediator() {
listenEvents();
return {
register: function(container) {
containers.push(container);
},
unregister: function(container) {
containers.splice(containers.indexOf(container), 1);
}
};
listenEvents();
return {
register: function(container) {
containers.push(container);
},
unregister: function(container) {
containers.splice(containers.indexOf(container), 1);
}
};
}

@@ -412,6 +461,2 @@

export default Mediator();
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc