Socket
Socket
Sign inDemoInstall

vue-slicksort

Package Overview
Dependencies
21
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0-alpha.0 to 2.0.0-alpha.1

2

dist/vue-slicksort.cjs.js

@@ -1055,3 +1055,3 @@ 'use strict';

var HandleDirective = {
bind: function bind(el) {
beforeMount: function beforeMount(el) {
el.sortableHandle = true;

@@ -1058,0 +1058,0 @@ }

@@ -1051,3 +1051,3 @@ import { h } from 'vue';

var HandleDirective = {
bind: function bind(el) {
beforeMount: function beforeMount(el) {
el.sortableHandle = true;

@@ -1054,0 +1054,0 @@ }

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],e):e(t.VueSlicksort={},t.vue)}(this,function(t,e){"use strict";var i={inject:["manager"],props:{index:{type:Number,required:!0},collection:{type:[String,Number],default:"default"},disabled:{type:Boolean,default:!1}},mounted:function(){var t=this.$props,e=t.collection,i=t.disabled,t=t.index;i||this.setDraggable(e,t)},watch:{index:function(t){this.$el&&this.$el.sortableInfo&&(this.$el.sortableInfo.index=t)},disabled:function(t){t?this.removeDraggable(this.collection):this.setDraggable(this.collection,this.index)},collection:function(t,e){this.removeDraggable(e),this.setDraggable(t,this.index)}},beforeUnmount:function(){var t=this.collection;this.disabled||this.removeDraggable(t)},methods:{setDraggable:function(t,e){var i=this.$el;i.sortableInfo={index:e,collection:t,manager:this.manager},this.ref={node:i},this.manager.add(t,this.ref)},removeDraggable:function(t){this.manager.remove(t,this.ref)}}},n=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function s(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function p(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)}var r=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var i=[],n=!0,s=!1,o=void 0;try{for(var r,a=t[Symbol.iterator]();!(n=(r=a.next()).done)&&(i.push(r.value),!e||i.length!==e);n=!0);}catch(t){s=!0,o=t}finally{try{!n&&a.return&&a.return()}finally{if(s)throw o}}return i}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},o=(function(t,e,i){return e&&s(t.prototype,e),i&&s(t,i),t}(a,[{key:"add",value:function(t,e){this.refs[t]||(this.refs[t]=[]),this.refs[t].push(e)}},{key:"remove",value:function(t,e){e=this.getIndex(t,e);-1!==e&&this.refs[t].splice(e,1)}},{key:"isActive",value:function(){return this.active}},{key:"getActive",value:function(){var e=this;return this.refs[this.active.collection].find(function(t){return t.node.sortableInfo.index==e.active.index})}},{key:"getIndex",value:function(t,e){return this.refs[t].indexOf(e)}},{key:"getOrderedRefs",value:function(t){t=0<arguments.length&&void 0!==t?t:this.active.collection;return this.refs[t].sort(function(t,e){return t.node.sortableInfo.index-e.node.sortableInfo.index})}}]),a);function a(){n(this,a),this.refs={}}function l(t,e,i){var n=t.slice(0);if(i>=n.length)for(var s=i-n.length;1+s--;)n.push(void 0);return n.splice(i,0,n.splice(e,1)[0]),n}var g={start:["touchstart","mousedown"],move:["touchmove","mousemove"],end:["touchend","touchcancel","mouseup"]},w=function(){if("undefined"==typeof window||"undefined"==typeof document)return"";var t=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],t=(Array.prototype.slice.call(t).join("").match(/-(moz|webkit|ms)-/)||""===t.OLink&&["","o"])[1];return"ms"!==t?t&&t.length?t[0].toUpperCase()+t.substr(1):"":"ms"}();function h(t,e){for(;t;){if(e(t))return t;t=t.parentNode}}function f(t,e,i){return i<t?t:e<i?e:i}function x(t){return"px"===t.substr(-2)?parseFloat(t):0}var d={emits:["sort-start","sort-move","sort-end","update:modelValue"],data:function(){return{sorting:!1,sortingIndex:null,manager:new o,events:{start:this.handleStart,move:this.handleMove,end:this.handleEnd}}},props:{modelValue:{type:Array,required:!0},axis:{type:String,default:"y"},distance:{type:Number,default:0},pressDelay:{type:Number,default:0},pressThreshold:{type:Number,default:5},useDragHandle:{type:Boolean,default:!1},useWindowAsScrollContainer:{type:Boolean,default:!1},hideSortableGhost:{type:Boolean,default:!0},lockToContainerEdges:{type:Boolean,default:!1},lockOffset:{type:[String,Number,Array],default:"50%"},transitionDuration:{type:Number,default:300},appendTo:{type:String,default:"body"},draggedSettlingDuration:{type:Number,default:null},lockAxis:String,helperClass:String,contentWindow:Object,shouldCancelStart:{type:Function,default:function(t){return-1!==["input","textarea","select","option","button"].indexOf(t.target.tagName.toLowerCase())}},getHelperDimensions:{type:Function,default:function(t){t=t.node;return{width:t.offsetWidth,height:t.offsetHeight}}}},provide:function(){return{manager:this.manager}},mounted:function(){var i=this;this.container=this.$el,this.document=this.container.ownerDocument||document,this._window=this.contentWindow||window,this.scrollContainer=this.useWindowAsScrollContainer?this.document.body:this.container;for(var t in this.events)!function(e){i.events.hasOwnProperty(e)&&g[e].forEach(function(t){return i.container.addEventListener(t,i.events[e],!1)})}(t)},beforeUnmount:function(){var t,i=this;for(t in this.events)!function(e){i.events.hasOwnProperty(e)&&g[e].forEach(function(t){return i.container.removeEventListener(t,i.events[e])})}(t)},methods:{handleStart:function(t){var e=this,i=this.$props,n=i.distance,s=i.shouldCancelStart;if(2===t.button||s(t))return!1;this._touched=!0,this._pos={x:t.pageX,y:t.pageY};var o=h(t.target,function(t){return null!=t.sortableInfo});o&&o.sortableInfo&&this.nodeIsChild(o)&&!this.sorting&&(i=this.$props.useDragHandle,o=(s=o.sortableInfo).index,s=s.collection,i&&!h(t.target,function(t){return null!=t.sortableHandle})||(this.manager.active={index:o,collection:s},"a"===t.target.tagName.toLowerCase()&&t.preventDefault(),n||(0===this.$props.pressDelay?this.handlePress(t):this.pressTimer=setTimeout(function(){return e.handlePress(t)},this.$props.pressDelay))))},nodeIsChild:function(t){return t.sortableInfo.manager===this.manager},handleMove:function(t){var e=this.$props,i=e.distance,n=e.pressThreshold;!this.sorting&&this._touched&&(this._delta={x:this._pos.x-t.pageX,y:this._pos.y-t.pageY},e=Math.abs(this._delta.x)+Math.abs(this._delta.y),i||n&&!(n&&n<=e)?i&&i<=e&&this.manager.isActive()&&this.handlePress(t):(clearTimeout(this.cancelTimer),this.cancelTimer=setTimeout(this.cancel,0)))},handleEnd:function(){var t=this.$props.distance;this._touched=!1,t||this.cancel()},cancel:function(){this.sorting||(clearTimeout(this.pressTimer),this.manager.active=null)},handlePress:function(t){var e,i,n,s,o,r,a,l,h,f,d,u=this,c=this.manager.getActive();c&&(f=(d=this.$props).axis,l=d.getHelperDimensions,e=d.helperClass,i=d.hideSortableGhost,n=d.useWindowAsScrollContainer,s=d.appendTo,o=c.node,r=c.collection,a=o.sortableInfo.index,d=o,c={top:x((d=window.getComputedStyle(d)).marginTop),right:x(d.marginRight),bottom:x(d.marginBottom),left:x(d.marginLeft)},d=this.container.getBoundingClientRect(),l=l({index:a,node:o,collection:r}),this.node=o,this.margin=c,this.width=l.width,this.height=l.height,this.marginOffset={x:this.margin.left+this.margin.right,y:Math.max(this.margin.top,this.margin.bottom)},this.boundingClientRect=o.getBoundingClientRect(),this.containerBoundingRect=d,this.index=a,this.newIndex=a,this._axis={x:0<=f.indexOf("x"),y:0<=f.indexOf("y")},this.offsetEdge=this.getEdgeOffset(o),this.initialOffset=this.getOffset(t),this.initialScroll={top:this.scrollContainer.scrollTop,left:this.scrollContainer.scrollLeft},this.initialWindowScroll={top:window.pageYOffset,left:window.pageXOffset},h=o.querySelectorAll("input, textarea, select"),f=o.cloneNode(!0),[].concat(p(f.querySelectorAll("input, textarea, select"))).forEach(function(t,e){"file"!==t.type&&h[e]&&(t.value=h[e].value)}),this.helper=this.document.querySelector(s).appendChild(f),this.helper.style.position="fixed",this.helper.style.top=this.boundingClientRect.top-c.top+"px",this.helper.style.left=this.boundingClientRect.left-c.left+"px",this.helper.style.width=this.width+"px",this.helper.style.height=this.height+"px",this.helper.style.boxSizing="border-box",this.helper.style.pointerEvents="none",i&&((this.sortableGhost=o).style.visibility="hidden",o.style.opacity=0),this.translate={},this.minTranslate={},this.maxTranslate={},this._axis.x&&(this.minTranslate.x=(n?0:d.left)-this.boundingClientRect.left-this.width/2,this.maxTranslate.x=(n?this._window.innerWidth:d.left+d.width)-this.boundingClientRect.left-this.width/2),this._axis.y&&(this.minTranslate.y=(n?0:d.top)-this.boundingClientRect.top-this.height/2,this.maxTranslate.y=(n?this._window.innerHeight:d.top+d.height)-this.boundingClientRect.top-this.height/2),e&&(d=this.helper.classList).add.apply(d,p(e.split(" "))),this.listenerNode=t.touches?o:this._window,g.move.forEach(function(t){return u.listenerNode.addEventListener(t,u.handleSortMove,!1)}),g.end.forEach(function(t){return u.listenerNode.addEventListener(t,u.handleSortEnd,!1)}),this.sorting=!0,this.sortingIndex=a,this.$emit("sort-start",{event:t,node:o,index:a,collection:r}))},handleSortMove:function(t){t.preventDefault(),this.updatePosition(t),this.animateNodes(),this.autoscroll(),this.$emit("sort-move",{event:t})},handleSortEnd:function(s){var o=this,r=this.manager.active.collection;this.listenerNode&&(g.move.forEach(function(t){return o.listenerNode.removeEventListener(t,o.handleSortMove)}),g.end.forEach(function(t){return o.listenerNode.removeEventListener(t,o.handleSortEnd)}));function t(){o.helper.parentNode.removeChild(o.helper),o.hideSortableGhost&&o.sortableGhost&&(o.sortableGhost.style.visibility="",o.sortableGhost.style.opacity="");for(var t=0,e=a.length;t<e;t++){var i=a[t],n=i.node;i.edgeOffset=null,n.style[w+"Transform"]="",n.style[w+"TransitionDuration"]=""}clearInterval(o.autoscrollInterval),o.autoscrollInterval=null,o.manager.active=null,o.sorting=!1,o.sortingIndex=null,o.$emit("sort-end",{event:s,oldIndex:o.index,newIndex:o.newIndex,collection:r}),o.$emit("update:modelValue",l(o.modelValue,o.index,o.newIndex)),o._touched=!1}var a=this.manager.refs[r];this.$props.transitionDuration||this.$props.draggedSettlingDuration?this.transitionHelperIntoPlace(a).then(t):t()},transitionHelperIntoPlace:function(t){var n=this;if(0===this.$props.draggedSettlingDuration)return Promise.resolve();var e=this.scrollContainer.scrollLeft-this.initialScroll.left,i=this.scrollContainer.scrollTop-this.initialScroll.top,s=t[this.index].node,t=t[this.newIndex].node,e=-e;this.translate&&0<this.translate.x?e+=t.offsetLeft+t.offsetWidth-(s.offsetLeft+s.offsetWidth):e+=t.offsetLeft-s.offsetLeft;i=-i;this.translate&&0<this.translate.y?i+=t.offsetTop+t.offsetHeight-(s.offsetTop+s.offsetHeight):i+=t.offsetTop-s.offsetTop;var o=null!==this.$props.draggedSettlingDuration?this.$props.draggedSettlingDuration:this.$props.transitionDuration;return this.helper.style[w+"Transform"]="translate3d("+e+"px,"+i+"px, 0)",this.helper.style[w+"TransitionDuration"]=o+"ms",new Promise(function(e){function t(t){t&&"transform"!==t.propertyName||(clearTimeout(i),n.helper.style[w+"Transform"]="",n.helper.style[w+"TransitionDuration"]="",e())}var i=setTimeout(t,o+10);n.helper.addEventListener("transitionend",t,!1)})},getEdgeOffset:function(t,e){e=1<arguments.length&&void 0!==e?e:{top:0,left:0};if(t){e={top:e.top+t.offsetTop,left:e.left+t.offsetLeft};return t.parentNode!==this.container?this.getEdgeOffset(t.parentNode,e):e}},getOffset:function(t){return{x:(t.touches?t.touches[0]:t).pageX,y:(t.touches?t.touches[0]:t).pageY}},getLockPixelOffsets:function(){var t=this.$props.lockOffset;if(Array.isArray(this.lockOffset)||(t=[t,t]),2!==t.length)throw new Error("lockOffset prop of SortableContainer should be a single value or an array of exactly two values. Given "+t);var e=r(t,2),t=e[0],e=e[1];return[this.getLockPixelOffset(t),this.getLockPixelOffset(e)]},getLockPixelOffset:function(t){var e=t,i=t,n="px";if("string"==typeof t){var s=/^[+-]?\d*(?:\.\d*)?(px|%)$/.exec(t);if(null===s)throw new Error('lockOffset value should be a number or a string of a number followed by "px" or "%". Given '+t);e=i=parseFloat(t),n=s[1]}if(!isFinite(e)||!isFinite(i))throw new Error("lockOffset value should be a finite. Given "+t);return"%"===n&&(e=e*this.width/100,i=i*this.height/100),{x:e,y:i}},updatePosition:function(t){var e=this.$props,i=e.lockAxis,n=e.lockToContainerEdges,s=this.getOffset(t),o={x:s.x-this.initialOffset.x,y:s.y-this.initialOffset.y};o.y-=window.pageYOffset-this.initialWindowScroll.top,o.x-=window.pageXOffset-this.initialWindowScroll.left,this.translate=o,n&&(e=this.getLockPixelOffsets(),s=(t=r(e,2))[0],n=t[1],e=this.width/2-s.x,t=this.height/2-s.y,s=this.width/2-n.x,n=this.height/2-n.y,o.x=f(this.minTranslate.x+e,this.maxTranslate.x-s,o.x),o.y=f(this.minTranslate.y+t,this.maxTranslate.y-n,o.y)),"x"===i?o.y=0:"y"===i&&(o.x=0),this.helper.style[w+"Transform"]="translate3d("+o.x+"px,"+o.y+"px, 0)"},animateNodes:function(){var t=this.$props,e=t.transitionDuration,i=t.hideSortableGhost,n=this.manager.getOrderedRefs(),s=this.scrollContainer.scrollLeft-this.initialScroll.left,t=this.scrollContainer.scrollTop-this.initialScroll.top,o=this.offsetEdge.left+this.translate.x+s,r=this.offsetEdge.top+this.translate.y+t,a=window.pageYOffset-this.initialWindowScroll.top,l=window.pageXOffset-this.initialWindowScroll.left;this.newIndex=null;for(var h=0,f=n.length;h<f;h++){var d=n[h].node,u=d.sortableInfo.index,c=d.offsetWidth,p=d.offsetHeight,g=this.width>c?c/2:this.width/2,x=this.height>p?p/2:this.height/2,m={x:0,y:0},y=n[h].edgeOffset;y||(n[h].edgeOffset=y=this.getEdgeOffset(d));var v=h<n.length-1&&n[h+1],c=0<h&&n[h-1];v&&!v.edgeOffset&&(v.edgeOffset=this.getEdgeOffset(v.node)),u!==this.index?(e&&(d.style[w+"TransitionDuration"]=e+"ms"),this._axis.x?this._axis.y?u<this.index&&(o+l-g<=y.left&&r+a<=y.top+x||r+a+x<=y.top)?(m.x=this.width+this.marginOffset.x,y.left+m.x>this.containerBoundingRect.width-g&&(m.x=v.edgeOffset.left-y.left,m.y=v.edgeOffset.top-y.top),null===this.newIndex&&(this.newIndex=u)):u>this.index&&(o+l+g>=y.left&&r+a+x>=y.top||r+a+x>=y.top+p)&&(m.x=-(this.width+this.marginOffset.x),y.left+m.x<this.containerBoundingRect.left+g&&(m.x=c.edgeOffset.left-y.left,m.y=c.edgeOffset.top-y.top),this.newIndex=u):u>this.index&&o+l+g>=y.left?(m.x=-(this.width+this.marginOffset.x),this.newIndex=u):u<this.index&&o+l<=y.left+g&&(m.x=this.width+this.marginOffset.x,null==this.newIndex&&(this.newIndex=u)):this._axis.y&&(u>this.index&&r+a+x>=y.top?(m.y=-(this.height+this.marginOffset.y),this.newIndex=u):u<this.index&&r+a<=y.top+x&&(m.y=this.height+this.marginOffset.y,null==this.newIndex&&(this.newIndex=u))),d.style[w+"Transform"]="translate3d("+m.x+"px,"+m.y+"px,0)"):i&&((this.sortableGhost=d).style.visibility="hidden",d.style.opacity=0)}null==this.newIndex&&(this.newIndex=this.index)},autoscroll:function(){var i=this,t=this.translate,n={x:0,y:0},s={x:1,y:1},e=10,o=10;t.y>=this.maxTranslate.y-this.height/2?(n.y=1,s.y=o*Math.abs((this.maxTranslate.y-this.height/2-t.y)/this.height)):t.x>=this.maxTranslate.x-this.width/2?(n.x=1,s.x=e*Math.abs((this.maxTranslate.x-this.width/2-t.x)/this.width)):t.y<=this.minTranslate.y+this.height/2?(n.y=-1,s.y=o*Math.abs((t.y-this.height/2-this.minTranslate.y)/this.height)):t.x<=this.minTranslate.x+this.width/2&&(n.x=-1,s.x=e*Math.abs((t.x-this.width/2-this.minTranslate.x)/this.width)),this.autoscrollInterval&&(clearInterval(this.autoscrollInterval),this.autoscrollInterval=null,this.isAutoScrolling=!1),0===n.x&&0===n.y||(this.autoscrollInterval=setInterval(function(){i.isAutoScrolling=!0;var t=+s.x*n.x,e=+s.y*n.y;i.scrollContainer.scrollTop+=e,i.scrollContainer.scrollLeft+=t,i.translate.x+=t,i.translate.y+=e,i.animateNodes()},5))}}},u={name:"slick-list",mixins:[d],render:function(){return e.h("div",this.$slots.default())}},c={name:"slick-item",mixins:[i],render:function(){return e.h("div",this.$slots.default())}};t.ElementMixin=i,t.ContainerMixin=d,t.HandleDirective={bind:function(t){t.sortableHandle=!0}},t.SlickList=u,t.SlickItem=c,t.arrayMove=l,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],e):e(t.VueSlicksort={},t.vue)}(this,function(t,e){"use strict";var i={inject:["manager"],props:{index:{type:Number,required:!0},collection:{type:[String,Number],default:"default"},disabled:{type:Boolean,default:!1}},mounted:function(){var t=this.$props,e=t.collection,i=t.disabled,t=t.index;i||this.setDraggable(e,t)},watch:{index:function(t){this.$el&&this.$el.sortableInfo&&(this.$el.sortableInfo.index=t)},disabled:function(t){t?this.removeDraggable(this.collection):this.setDraggable(this.collection,this.index)},collection:function(t,e){this.removeDraggable(e),this.setDraggable(t,this.index)}},beforeUnmount:function(){var t=this.collection;this.disabled||this.removeDraggable(t)},methods:{setDraggable:function(t,e){var i=this.$el;i.sortableInfo={index:e,collection:t,manager:this.manager},this.ref={node:i},this.manager.add(t,this.ref)},removeDraggable:function(t){this.manager.remove(t,this.ref)}}},n=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function s(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function p(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)}var r=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var i=[],n=!0,s=!1,o=void 0;try{for(var r,a=t[Symbol.iterator]();!(n=(r=a.next()).done)&&(i.push(r.value),!e||i.length!==e);n=!0);}catch(t){s=!0,o=t}finally{try{!n&&a.return&&a.return()}finally{if(s)throw o}}return i}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},o=(function(t,e,i){return e&&s(t.prototype,e),i&&s(t,i),t}(a,[{key:"add",value:function(t,e){this.refs[t]||(this.refs[t]=[]),this.refs[t].push(e)}},{key:"remove",value:function(t,e){e=this.getIndex(t,e);-1!==e&&this.refs[t].splice(e,1)}},{key:"isActive",value:function(){return this.active}},{key:"getActive",value:function(){var e=this;return this.refs[this.active.collection].find(function(t){return t.node.sortableInfo.index==e.active.index})}},{key:"getIndex",value:function(t,e){return this.refs[t].indexOf(e)}},{key:"getOrderedRefs",value:function(t){t=0<arguments.length&&void 0!==t?t:this.active.collection;return this.refs[t].sort(function(t,e){return t.node.sortableInfo.index-e.node.sortableInfo.index})}}]),a);function a(){n(this,a),this.refs={}}function l(t,e,i){var n=t.slice(0);if(i>=n.length)for(var s=i-n.length;1+s--;)n.push(void 0);return n.splice(i,0,n.splice(e,1)[0]),n}var g={start:["touchstart","mousedown"],move:["touchmove","mousemove"],end:["touchend","touchcancel","mouseup"]},w=function(){if("undefined"==typeof window||"undefined"==typeof document)return"";var t=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],t=(Array.prototype.slice.call(t).join("").match(/-(moz|webkit|ms)-/)||""===t.OLink&&["","o"])[1];return"ms"!==t?t&&t.length?t[0].toUpperCase()+t.substr(1):"":"ms"}();function h(t,e){for(;t;){if(e(t))return t;t=t.parentNode}}function f(t,e,i){return i<t?t:e<i?e:i}function x(t){return"px"===t.substr(-2)?parseFloat(t):0}var d={emits:["sort-start","sort-move","sort-end","update:modelValue"],data:function(){return{sorting:!1,sortingIndex:null,manager:new o,events:{start:this.handleStart,move:this.handleMove,end:this.handleEnd}}},props:{modelValue:{type:Array,required:!0},axis:{type:String,default:"y"},distance:{type:Number,default:0},pressDelay:{type:Number,default:0},pressThreshold:{type:Number,default:5},useDragHandle:{type:Boolean,default:!1},useWindowAsScrollContainer:{type:Boolean,default:!1},hideSortableGhost:{type:Boolean,default:!0},lockToContainerEdges:{type:Boolean,default:!1},lockOffset:{type:[String,Number,Array],default:"50%"},transitionDuration:{type:Number,default:300},appendTo:{type:String,default:"body"},draggedSettlingDuration:{type:Number,default:null},lockAxis:String,helperClass:String,contentWindow:Object,shouldCancelStart:{type:Function,default:function(t){return-1!==["input","textarea","select","option","button"].indexOf(t.target.tagName.toLowerCase())}},getHelperDimensions:{type:Function,default:function(t){t=t.node;return{width:t.offsetWidth,height:t.offsetHeight}}}},provide:function(){return{manager:this.manager}},mounted:function(){var i=this;this.container=this.$el,this.document=this.container.ownerDocument||document,this._window=this.contentWindow||window,this.scrollContainer=this.useWindowAsScrollContainer?this.document.body:this.container;for(var t in this.events)!function(e){i.events.hasOwnProperty(e)&&g[e].forEach(function(t){return i.container.addEventListener(t,i.events[e],!1)})}(t)},beforeUnmount:function(){var t,i=this;for(t in this.events)!function(e){i.events.hasOwnProperty(e)&&g[e].forEach(function(t){return i.container.removeEventListener(t,i.events[e])})}(t)},methods:{handleStart:function(t){var e=this,i=this.$props,n=i.distance,s=i.shouldCancelStart;if(2===t.button||s(t))return!1;this._touched=!0,this._pos={x:t.pageX,y:t.pageY};var o=h(t.target,function(t){return null!=t.sortableInfo});o&&o.sortableInfo&&this.nodeIsChild(o)&&!this.sorting&&(i=this.$props.useDragHandle,o=(s=o.sortableInfo).index,s=s.collection,i&&!h(t.target,function(t){return null!=t.sortableHandle})||(this.manager.active={index:o,collection:s},"a"===t.target.tagName.toLowerCase()&&t.preventDefault(),n||(0===this.$props.pressDelay?this.handlePress(t):this.pressTimer=setTimeout(function(){return e.handlePress(t)},this.$props.pressDelay))))},nodeIsChild:function(t){return t.sortableInfo.manager===this.manager},handleMove:function(t){var e=this.$props,i=e.distance,n=e.pressThreshold;!this.sorting&&this._touched&&(this._delta={x:this._pos.x-t.pageX,y:this._pos.y-t.pageY},e=Math.abs(this._delta.x)+Math.abs(this._delta.y),i||n&&!(n&&n<=e)?i&&i<=e&&this.manager.isActive()&&this.handlePress(t):(clearTimeout(this.cancelTimer),this.cancelTimer=setTimeout(this.cancel,0)))},handleEnd:function(){var t=this.$props.distance;this._touched=!1,t||this.cancel()},cancel:function(){this.sorting||(clearTimeout(this.pressTimer),this.manager.active=null)},handlePress:function(t){var e,i,n,s,o,r,a,l,h,f,d,u=this,c=this.manager.getActive();c&&(f=(d=this.$props).axis,l=d.getHelperDimensions,e=d.helperClass,i=d.hideSortableGhost,n=d.useWindowAsScrollContainer,s=d.appendTo,o=c.node,r=c.collection,a=o.sortableInfo.index,d=o,c={top:x((d=window.getComputedStyle(d)).marginTop),right:x(d.marginRight),bottom:x(d.marginBottom),left:x(d.marginLeft)},d=this.container.getBoundingClientRect(),l=l({index:a,node:o,collection:r}),this.node=o,this.margin=c,this.width=l.width,this.height=l.height,this.marginOffset={x:this.margin.left+this.margin.right,y:Math.max(this.margin.top,this.margin.bottom)},this.boundingClientRect=o.getBoundingClientRect(),this.containerBoundingRect=d,this.index=a,this.newIndex=a,this._axis={x:0<=f.indexOf("x"),y:0<=f.indexOf("y")},this.offsetEdge=this.getEdgeOffset(o),this.initialOffset=this.getOffset(t),this.initialScroll={top:this.scrollContainer.scrollTop,left:this.scrollContainer.scrollLeft},this.initialWindowScroll={top:window.pageYOffset,left:window.pageXOffset},h=o.querySelectorAll("input, textarea, select"),f=o.cloneNode(!0),[].concat(p(f.querySelectorAll("input, textarea, select"))).forEach(function(t,e){"file"!==t.type&&h[e]&&(t.value=h[e].value)}),this.helper=this.document.querySelector(s).appendChild(f),this.helper.style.position="fixed",this.helper.style.top=this.boundingClientRect.top-c.top+"px",this.helper.style.left=this.boundingClientRect.left-c.left+"px",this.helper.style.width=this.width+"px",this.helper.style.height=this.height+"px",this.helper.style.boxSizing="border-box",this.helper.style.pointerEvents="none",i&&((this.sortableGhost=o).style.visibility="hidden",o.style.opacity=0),this.translate={},this.minTranslate={},this.maxTranslate={},this._axis.x&&(this.minTranslate.x=(n?0:d.left)-this.boundingClientRect.left-this.width/2,this.maxTranslate.x=(n?this._window.innerWidth:d.left+d.width)-this.boundingClientRect.left-this.width/2),this._axis.y&&(this.minTranslate.y=(n?0:d.top)-this.boundingClientRect.top-this.height/2,this.maxTranslate.y=(n?this._window.innerHeight:d.top+d.height)-this.boundingClientRect.top-this.height/2),e&&(d=this.helper.classList).add.apply(d,p(e.split(" "))),this.listenerNode=t.touches?o:this._window,g.move.forEach(function(t){return u.listenerNode.addEventListener(t,u.handleSortMove,!1)}),g.end.forEach(function(t){return u.listenerNode.addEventListener(t,u.handleSortEnd,!1)}),this.sorting=!0,this.sortingIndex=a,this.$emit("sort-start",{event:t,node:o,index:a,collection:r}))},handleSortMove:function(t){t.preventDefault(),this.updatePosition(t),this.animateNodes(),this.autoscroll(),this.$emit("sort-move",{event:t})},handleSortEnd:function(s){var o=this,r=this.manager.active.collection;this.listenerNode&&(g.move.forEach(function(t){return o.listenerNode.removeEventListener(t,o.handleSortMove)}),g.end.forEach(function(t){return o.listenerNode.removeEventListener(t,o.handleSortEnd)}));function t(){o.helper.parentNode.removeChild(o.helper),o.hideSortableGhost&&o.sortableGhost&&(o.sortableGhost.style.visibility="",o.sortableGhost.style.opacity="");for(var t=0,e=a.length;t<e;t++){var i=a[t],n=i.node;i.edgeOffset=null,n.style[w+"Transform"]="",n.style[w+"TransitionDuration"]=""}clearInterval(o.autoscrollInterval),o.autoscrollInterval=null,o.manager.active=null,o.sorting=!1,o.sortingIndex=null,o.$emit("sort-end",{event:s,oldIndex:o.index,newIndex:o.newIndex,collection:r}),o.$emit("update:modelValue",l(o.modelValue,o.index,o.newIndex)),o._touched=!1}var a=this.manager.refs[r];this.$props.transitionDuration||this.$props.draggedSettlingDuration?this.transitionHelperIntoPlace(a).then(t):t()},transitionHelperIntoPlace:function(t){var n=this;if(0===this.$props.draggedSettlingDuration)return Promise.resolve();var e=this.scrollContainer.scrollLeft-this.initialScroll.left,i=this.scrollContainer.scrollTop-this.initialScroll.top,s=t[this.index].node,t=t[this.newIndex].node,e=-e;this.translate&&0<this.translate.x?e+=t.offsetLeft+t.offsetWidth-(s.offsetLeft+s.offsetWidth):e+=t.offsetLeft-s.offsetLeft;i=-i;this.translate&&0<this.translate.y?i+=t.offsetTop+t.offsetHeight-(s.offsetTop+s.offsetHeight):i+=t.offsetTop-s.offsetTop;var o=null!==this.$props.draggedSettlingDuration?this.$props.draggedSettlingDuration:this.$props.transitionDuration;return this.helper.style[w+"Transform"]="translate3d("+e+"px,"+i+"px, 0)",this.helper.style[w+"TransitionDuration"]=o+"ms",new Promise(function(e){function t(t){t&&"transform"!==t.propertyName||(clearTimeout(i),n.helper.style[w+"Transform"]="",n.helper.style[w+"TransitionDuration"]="",e())}var i=setTimeout(t,o+10);n.helper.addEventListener("transitionend",t,!1)})},getEdgeOffset:function(t,e){e=1<arguments.length&&void 0!==e?e:{top:0,left:0};if(t){e={top:e.top+t.offsetTop,left:e.left+t.offsetLeft};return t.parentNode!==this.container?this.getEdgeOffset(t.parentNode,e):e}},getOffset:function(t){return{x:(t.touches?t.touches[0]:t).pageX,y:(t.touches?t.touches[0]:t).pageY}},getLockPixelOffsets:function(){var t=this.$props.lockOffset;if(Array.isArray(this.lockOffset)||(t=[t,t]),2!==t.length)throw new Error("lockOffset prop of SortableContainer should be a single value or an array of exactly two values. Given "+t);var e=r(t,2),t=e[0],e=e[1];return[this.getLockPixelOffset(t),this.getLockPixelOffset(e)]},getLockPixelOffset:function(t){var e=t,i=t,n="px";if("string"==typeof t){var s=/^[+-]?\d*(?:\.\d*)?(px|%)$/.exec(t);if(null===s)throw new Error('lockOffset value should be a number or a string of a number followed by "px" or "%". Given '+t);e=i=parseFloat(t),n=s[1]}if(!isFinite(e)||!isFinite(i))throw new Error("lockOffset value should be a finite. Given "+t);return"%"===n&&(e=e*this.width/100,i=i*this.height/100),{x:e,y:i}},updatePosition:function(t){var e=this.$props,i=e.lockAxis,n=e.lockToContainerEdges,s=this.getOffset(t),o={x:s.x-this.initialOffset.x,y:s.y-this.initialOffset.y};o.y-=window.pageYOffset-this.initialWindowScroll.top,o.x-=window.pageXOffset-this.initialWindowScroll.left,this.translate=o,n&&(e=this.getLockPixelOffsets(),s=(t=r(e,2))[0],n=t[1],e=this.width/2-s.x,t=this.height/2-s.y,s=this.width/2-n.x,n=this.height/2-n.y,o.x=f(this.minTranslate.x+e,this.maxTranslate.x-s,o.x),o.y=f(this.minTranslate.y+t,this.maxTranslate.y-n,o.y)),"x"===i?o.y=0:"y"===i&&(o.x=0),this.helper.style[w+"Transform"]="translate3d("+o.x+"px,"+o.y+"px, 0)"},animateNodes:function(){var t=this.$props,e=t.transitionDuration,i=t.hideSortableGhost,n=this.manager.getOrderedRefs(),s=this.scrollContainer.scrollLeft-this.initialScroll.left,t=this.scrollContainer.scrollTop-this.initialScroll.top,o=this.offsetEdge.left+this.translate.x+s,r=this.offsetEdge.top+this.translate.y+t,a=window.pageYOffset-this.initialWindowScroll.top,l=window.pageXOffset-this.initialWindowScroll.left;this.newIndex=null;for(var h=0,f=n.length;h<f;h++){var d=n[h].node,u=d.sortableInfo.index,c=d.offsetWidth,p=d.offsetHeight,g=this.width>c?c/2:this.width/2,x=this.height>p?p/2:this.height/2,m={x:0,y:0},y=n[h].edgeOffset;y||(n[h].edgeOffset=y=this.getEdgeOffset(d));var v=h<n.length-1&&n[h+1],c=0<h&&n[h-1];v&&!v.edgeOffset&&(v.edgeOffset=this.getEdgeOffset(v.node)),u!==this.index?(e&&(d.style[w+"TransitionDuration"]=e+"ms"),this._axis.x?this._axis.y?u<this.index&&(o+l-g<=y.left&&r+a<=y.top+x||r+a+x<=y.top)?(m.x=this.width+this.marginOffset.x,y.left+m.x>this.containerBoundingRect.width-g&&(m.x=v.edgeOffset.left-y.left,m.y=v.edgeOffset.top-y.top),null===this.newIndex&&(this.newIndex=u)):u>this.index&&(o+l+g>=y.left&&r+a+x>=y.top||r+a+x>=y.top+p)&&(m.x=-(this.width+this.marginOffset.x),y.left+m.x<this.containerBoundingRect.left+g&&(m.x=c.edgeOffset.left-y.left,m.y=c.edgeOffset.top-y.top),this.newIndex=u):u>this.index&&o+l+g>=y.left?(m.x=-(this.width+this.marginOffset.x),this.newIndex=u):u<this.index&&o+l<=y.left+g&&(m.x=this.width+this.marginOffset.x,null==this.newIndex&&(this.newIndex=u)):this._axis.y&&(u>this.index&&r+a+x>=y.top?(m.y=-(this.height+this.marginOffset.y),this.newIndex=u):u<this.index&&r+a<=y.top+x&&(m.y=this.height+this.marginOffset.y,null==this.newIndex&&(this.newIndex=u))),d.style[w+"Transform"]="translate3d("+m.x+"px,"+m.y+"px,0)"):i&&((this.sortableGhost=d).style.visibility="hidden",d.style.opacity=0)}null==this.newIndex&&(this.newIndex=this.index)},autoscroll:function(){var i=this,t=this.translate,n={x:0,y:0},s={x:1,y:1},e=10,o=10;t.y>=this.maxTranslate.y-this.height/2?(n.y=1,s.y=o*Math.abs((this.maxTranslate.y-this.height/2-t.y)/this.height)):t.x>=this.maxTranslate.x-this.width/2?(n.x=1,s.x=e*Math.abs((this.maxTranslate.x-this.width/2-t.x)/this.width)):t.y<=this.minTranslate.y+this.height/2?(n.y=-1,s.y=o*Math.abs((t.y-this.height/2-this.minTranslate.y)/this.height)):t.x<=this.minTranslate.x+this.width/2&&(n.x=-1,s.x=e*Math.abs((t.x-this.width/2-this.minTranslate.x)/this.width)),this.autoscrollInterval&&(clearInterval(this.autoscrollInterval),this.autoscrollInterval=null,this.isAutoScrolling=!1),0===n.x&&0===n.y||(this.autoscrollInterval=setInterval(function(){i.isAutoScrolling=!0;var t=+s.x*n.x,e=+s.y*n.y;i.scrollContainer.scrollTop+=e,i.scrollContainer.scrollLeft+=t,i.translate.x+=t,i.translate.y+=e,i.animateNodes()},5))}}},u={name:"slick-list",mixins:[d],render:function(){return e.h("div",this.$slots.default())}},c={name:"slick-item",mixins:[i],render:function(){return e.h("div",this.$slots.default())}};t.ElementMixin=i,t.ContainerMixin=d,t.HandleDirective={beforeMount:function(t){t.sortableHandle=!0}},t.SlickList=u,t.SlickItem=c,t.arrayMove=l,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=vue-slicksort.min.js.map

@@ -1055,3 +1055,3 @@ (function (global, factory) {

var HandleDirective = {
bind: function bind(el) {
beforeMount: function beforeMount(el) {
el.sortableHandle = true;

@@ -1058,0 +1058,0 @@ }

{
"name": "vue-slicksort",
"version": "2.0.0-alpha.0",
"version": "2.0.0-alpha.1",
"description": "Set of mixins to turn any list into a sortable, touch-friendly, animated list",

@@ -5,0 +5,0 @@ "author": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc