Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Typescript declaration file for the Draggabilly library. #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions typings/draggabilly.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Type definition for Draggabilly

/// <reference path="../jquery/jquery.d.ts" />

/**
* Declare the module for options and other stuff
*/
declare module Draggabilly {
// Interface for the draggabilly options
interface IDraggabillyOptions {
handle?: any;
containment?: boolean;
axis?: string;
grid?: [number, number];
}

// Interface for the movevector
interface IMoveVector {
x: number;
y: number;
}
}

/**
* Interface for the main object
*/
interface Draggabilly {
new (element: any, options: Draggabilly.IDraggabillyOptions);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't options be an optional parameter?


// The on methods for usage in VanillaJS
on(eventName: string, handler: (event: any, pointer: any) => {});
on(eventName: string, handler: (event: any, pointer: any, moveVector: Draggabilly.IMoveVector) => {});

// The off methods for usage in VanillaJS
off(eventName: string, handler: (event: any, pointer: any) => {});
off(eventName: string, handler: (event: any, pointer: any, moveVector: Draggabilly.IMoveVector) => {});

// The once methods for usage in VanillaJS
once(eventName: string, handler: (event: any, pointer: any) => {});
once(eventName: string, handler: (event: any, pointer: any, moveVector: Draggabilly.IMoveVector) => {});

// Disable the dragging
disable();

// Destroy the draggable object
destroy();

// Enable the dragging
enable();
}

/**
* Extend the JQuery interface
*/
interface JQuery {
// Initialize a draggable object
draggabilly(options: Draggabilly.IDraggabillyOptions): JQuery;

// Enable, disable or destroy the dragging
draggabilly(method: string);
}