From 1bdaeb9cbfade9ba325392fde20f5e9d57d0c72e Mon Sep 17 00:00:00 2001 From: Jason Wu Date: Sun, 2 Jul 2017 11:47:34 -0500 Subject: [PATCH] Wrote it as an external module --- types/draggabilly/index.d.ts | 50 ++++++++++++++------------------- types/draggabilly/tsconfig.json | 2 +- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/types/draggabilly/index.d.ts b/types/draggabilly/index.d.ts index c614796ca9..f376ea8fbd 100644 --- a/types/draggabilly/index.d.ts +++ b/types/draggabilly/index.d.ts @@ -4,43 +4,35 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -// export = Backbone; -// export as namespace Backbone; +export interface Position { + x: number; + y: number; +} -declare module 'draggabilly' { - interface Position { - x: number; - y: number; - } +export interface DraggabillyOptions { + axis?: 'x' | 'y'; + containment?: Element | string | boolean; + grid?: [number, number]; + handle?: string; +} - export interface DraggabillyOptions { - axis?: 'x' | 'y'; - containment?: Element | string | boolean; - grid?: [number, number]; - handle?: string; - } +export type DraggabillyEventName = 'dragStart' | 'dragMove' | 'dragEnd' | 'pointerDown' | 'pointerMove' | 'pointerUp' + | 'staticClick'; - export type DraggabillyEventName = 'dragStart' | 'dragMove' | 'dragEnd' | 'pointerDown' | 'pointerMove' | 'pointerUp' - | 'staticClick'; +export default class Draggabilly { + position: Position; - export default class Draggabilly { - position: Position; + constructor(element: Element | string, options?: DraggabillyOptions); - constructor(element: Element | string, options?: DraggabillyOptions); + on(eventName: DraggabillyEventName, listener: (event: Event, pointer: MouseEvent | Touch, moveVector: Position) => void): Draggabilly; - on(eventName: DraggabillyEventName, - listener: (event: Event, pointer: MouseEvent | Touch, moveVector: Position) => void): void; + off(eventName: DraggabillyEventName, listener: (event: Event, pointer: MouseEvent | Touch, moveVector: Position) => void): Draggabilly; - off(eventName: DraggabillyEventName, - listener: (event: Event, pointer: MouseEvent | Touch, moveVector: Position) => void): void; + once(eventName: DraggabillyEventName, listener: (event: Event, pointer: MouseEvent | Touch, moveVector?: Position) => void): Draggabilly; - once(eventName: DraggabillyEventName, - listener: (event: Event, pointer: MouseEvent | Touch, moveVector?: Position) => void): void; + enable(): void; - enable(): void; + disable(): void; - disable(): void; - - destroy(): void; - } + destroy(): void; } diff --git a/types/draggabilly/tsconfig.json b/types/draggabilly/tsconfig.json index c0873c7293..32cc6ee235 100644 --- a/types/draggabilly/tsconfig.json +++ b/types/draggabilly/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../"