From c7447fc395f8c0576d7716800e1ce752438cbdda Mon Sep 17 00:00:00 2001 From: Dan Manastireanu <498419+danmana@users.noreply.github.com> Date: Fri, 19 Oct 2018 17:42:25 +0300 Subject: [PATCH] @types/dragula Add chaining support. Closes #15422 --- types/dragula/dragula-tests.ts | 11 +++++++++++ types/dragula/index.d.ts | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/types/dragula/dragula-tests.ts b/types/dragula/dragula-tests.ts index 5f143406c3..0e6280ae61 100644 --- a/types/dragula/dragula-tests.ts +++ b/types/dragula/dragula-tests.ts @@ -30,3 +30,14 @@ var drake = dragula({ copy: true }); drake.containers.push(document.querySelector('#container')); + +dragula([document.getElementById('left'), document.getElementById('right')]) + .on('drag', function (el: Element) { + el.className = el.className.replace('ex-moved', ''); + }).on('drop', function (el: Element) { + el.className += ' ex-moved'; + }).on('over', function (el: Element, container: Element) { + container.className += ' ex-over'; + }).on('out', function (el: Element, container: Element) { + container.className = container.className.replace('ex-over', ''); + }); diff --git a/types/dragula/index.d.ts b/types/dragula/index.d.ts index 51998fb583..925a586971 100644 --- a/types/dragula/index.d.ts +++ b/types/dragula/index.d.ts @@ -33,7 +33,7 @@ declare namespace dragula { cancel(revert:boolean): void; cancel(): void; remove(): void; - on(events: string, callback: Function): void; + on(events: string, callback: Function): Drake; destroy(): void; }