add dragula definition

This commit is contained in:
Paul Welter
2015-08-05 23:00:03 -05:00
parent 983126e131
commit e8bdd1be7c
5 changed files with 116 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
import dragula = require("dragula");
// containers
var d1 = dragula([document.querySelector('#left'), document.querySelector('#right')]);
// all options
var d2 = dragula({
isContainer: function (el) {
return false;
},
moves: function (el, container, handle) {
return true;
},
accepts: function (el, target, source, sibling) {
return true;
},
invalid: function (el, target) {
return el.tagName === 'A' || el.tagName === 'BUTTON';
},
direction: 'vertical',
copy: false,
revertOnSpill: false,
removeOnSpill: false,
delay: false,
mirrorContainer: document.body
});
// empty call
var d3 = dragula();
// drake API
var drake = dragula({
copy: true
});
drake.containers.push(document.querySelector('#container'));
+1
View File
@@ -0,0 +1 @@
--experimentalDecorators --target ES5 --module amd
+31
View File
@@ -0,0 +1,31 @@
/// <reference path="dragula.d.ts" />
var d1 = dragula([document.querySelector('#left'), document.querySelector('#right')]);
var d2 = dragula({
isContainer: function (el) {
return false;
},
moves: function (el, container, handle) {
return true;
},
accepts: function (el, target, source, sibling) {
return true;
},
invalid: function (el, target) {
return el.tagName === 'A' || el.tagName === 'BUTTON';
},
direction: 'vertical',
copy: false,
revertOnSpill: false,
removeOnSpill: false,
delay: false,
mirrorContainer: document.body
});
var d3 = dragula();
var drake = dragula({
copy: true
});
drake.containers.push(document.querySelector('#container'));
+1
View File
@@ -0,0 +1 @@
+46
View File
@@ -0,0 +1,46 @@
// Type definitions for dragula v2.1.2
// Project: http://bevacqua.github.io/dragula/
// Definitions by: Paul Welter <https://github.com/pwelter34/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module dragula {
interface DragulaOptions {
containers?: Element[];
isContainer?: (el?: Element) => boolean;
moves?: (el?: Element, container?: Element, handle?: Element) => boolean;
accepts?: (el?: Element, target?: Element, source?: Element, sibling?: Element) => boolean;
invalid?: (el?: Element, target?: Element) => boolean;
direction?: string;
copy?: boolean;
revertOnSpill?: boolean;
removeOnSpill?: boolean;
delay?: boolean | number;
mirrorContainer?: Element;
}
interface Drake {
containers: Element[];
dragging: boolean;
start(item:Element): void;
end(): void;
cancel(revert:boolean): void;
cancel(): void;
remove(): void;
on(events: string, callback: Function): void;
destroy(): void;
}
interface Dragula {
(containers: Element[], options: DragulaOptions): Drake;
(containers: Element, options: DragulaOptions): Drake;
(containers: Element[]): Drake;
(options: DragulaOptions): Drake;
(): Drake;
}
}
declare var dragula: dragula.Dragula;
declare module "dragula" {
export = dragula;
}