Sortablejs: Types for group option.

This commit is contained in:
Maarten Staa
2018-09-20 15:06:59 +02:00
parent 8378a65683
commit c635092f03
2 changed files with 68 additions and 2 deletions
+8 -1
View File
@@ -88,8 +88,15 @@ declare namespace Sortable {
willInsertAfter?: boolean;
}
export interface GroupOptions {
name: string;
pull?: boolean | 'clone' | ((to: Sortable, from: Sortable) => boolean | string);
put?: boolean | string | string[] | ((to: Sortable) => boolean);
revertClone?: boolean;
}
export interface Options {
group?: any;
group?: string | GroupOptions;
sort?: boolean;
delay?: number;
disabled?: boolean;
+60 -1
View File
@@ -197,7 +197,7 @@ simpleList.innerHTML = Array.apply(null, new Array(100)).map(function(value: any
},
{
name: 'advanced',
pull: 'clone',
pull: 'clone' as 'clone',
put: false
}, {
name: 'advanced',
@@ -297,3 +297,62 @@ document.addEventListener("DOMContentLoaded", function() {
setNoiseBackground(document.getElementsByTagName('body')[0], 50, 50, 0.02);
}, false);
Sortable.create(simpleList, {
group: 'foo',
animation: 100
});
Sortable.create(simpleList, {
group: 'bar',
animation: 100
});
Sortable.create(simpleList, {
group: {
name: 'qux',
put: ['foo', 'bar']
},
animation: 100
});
Sortable.create(simpleList, {
group: 'foo',
animation: 100
});
Sortable.create(simpleList, {
group: {
name: 'bar',
put: 'qux',
pull: function (to, from) {
return from.el.children.length > 2 || 'clone';
}
},
animation: 100
});
Sortable.create(simpleList, {
group: {
name: 'qux',
put: function (to) {
return to.el.children.length < 4;
}
},
animation: 100
});
Sortable.create(simpleList, {
animation: 200,
group: {
name: "shared",
pull: "clone",
revertClone: true,
},
sort: true
});
Sortable.create(simpleList, {
group: "shared",
sort: false
});