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

vue-sortable2

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-sortable2 - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

.npmignore

13

package.json
{
"name": "vue-sortable2",
"version": "0.0.2",
"version": "0.0.3",
"description": "vue-sortable",

@@ -10,3 +10,5 @@ "main": "vue-sortable.js",

},
"author": "NangeGao",
"author": {
"name": "NangeGao"
},
"license": "MIT",

@@ -26,3 +28,8 @@ "dependencies": {

"sortable"
]
],
"gitHead": "def4d15c39c98771866ceed946806fa189f396f7",
"readme": "ERROR: No README data found!",
"_id": "vue-sortable2@0.0.2",
"_shasum": "9856f5c9f4d0d1be98923bab202453396e8a9261",
"_from": "vue-sortable2@0.0.2"
}

@@ -16,30 +16,40 @@ ;(function () {

vSortable.install = function (Vue) {
Vue.directive('sortable', function (data) {
var options = {
onUpdate (evt) {
var sort = []; //每个位置上存放的item的index
data.forEach((item, index) => {
sort[item.select_sort-1] = index;
});
var operateItem = sort.splice(evt.oldIndex, 1);
sort.splice(evt.newIndex, 0, operateItem[0]);
for(var i=0,len=sort.length; i<len; i++) {
data[sort[i]].select_sort = i+1;
}
}
};
Vue.directive('sortable', {
bind (el, binding, vnode) {
var sortable = new Sortable(this.el, options)
console.log(el);
console.log(binding);
console.log(vnode);
//return;
if (this.arg && !this.vm.sortable) {
this.vm.sortable = {}
}
var data = binding.value;
var options = {
onUpdate (evt) {
var sort = []; //每个位置上存放的item的index
data.forEach((item, index) => {
sort[item.select_sort-1] = index;
});
var operateItem = sort.splice(evt.oldIndex, 1);
sort.splice(evt.newIndex, 0, operateItem[0]);
for(var i=0,len=sort.length; i<len; i++) {
data[sort[i]].select_sort = i+1;
}
}
};
// Throw an error if the given ID is not unique
if (this.arg && this.vm.sortable[this.arg]) {
console.warn('[vue-sortable] cannot set already defined sortable id: \'' + this.arg + '\'')
} else if( this.arg ) {
this.vm.sortable[this.arg] = sortable
}
})
var sortable = new Sortable(el, options)
if (this.arg && !this.vm.sortable) {
this.vm.sortable = {}
}
// Throw an error if the given ID is not unique
if (this.arg && this.vm.sortable[this.arg]) {
console.warn('[vue-sortable] cannot set already defined sortable id: \'' + this.arg + '\'')
} else if( this.arg ) {
this.vm.sortable[this.arg] = sortable
}
}
});
}

@@ -46,0 +56,0 @@

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