DefinitelyTyped/types/waypoints/index.d.ts
Sergei Dorogin d72c2f781d waypoints.jquery: jQuery Adapter of waypoints 4.x (jquery.waypoints) (#23170)
* jQuery Adapter of waypoints 4.x (jquery.waypoints)

waypoints: refactoring of WaypointOptions to allow waypoint.jquery definition (common options extracted into base interface - WaypointOptionsBase)

* waypoints.jquery: set TypeScript version as 2.3

* waypoints.jquery: fixes: context moved to WaypointOptionsJQuery and WaypointOptions; waypoints-jquery-tests.ts renamed to waypoints.jquery-tests.ts

* waypoints.jquery: fixes: removed BOM in waypoints.jquery-tests.ts

* waypoints: waypoints.jquery has been moved into waypoints (as waypoints/jquery.d.ts)

* waypoints: fixes: waypoints-tests.ts: fixed prefer-const  Identifier 'waypoint1' is never reassigned; use 'const' instead of 'let'.
2018-01-25 09:13:42 -08:00

84 lines
2.6 KiB
TypeScript

// Type definitions for waypoints 4.x
// Project: https://github.com/imakewebthings/waypoints
// Definitions by: Dominik Bułaj <https://github.com/dominikbulaj>, Alexey Kolotovchenkov <https://github.com/Koloto>, Sergei Dorogin <https://github.com/evil-shrike>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
interface WaypointOptionsBase {
offset?: string|number|(() => number);
continuous?: boolean;
enabled?: boolean;
group?: string;
horizontal?: boolean;
}
interface WaypointOptions extends WaypointOptionsBase {
element: HTMLElement;
handler: (this: Waypoint, direction?: string) => void;
context?: HTMLElement;
}
declare class WaypointGroup {
first: () => Waypoint;
last: () => Waypoint;
name: string;
axis: string;
waypoints: Waypoint[];
}
declare class WaypointContext {
adapter: WaypointAdapter;
element: HTMLElement|Window;
waypoints: {horizontal: {}, vertical: {}}; // http://imakewebthings.com/waypoints/api/context/#waypoints-property
destroy: () => Waypoint;
refresh: () => Waypoint;
}
declare class WaypointAdapter {
constructor(element: HTMLElement);
innerHeight(): number;
innerWidth(): number;
off(event: string): undefined;
offset(): {top: number, left: number};
on(event: string, handler: () => void): undefined;
outerHeight(includeMargin: boolean): number;
outerWidth(includeMargin: boolean): number;
scrollLeft(): number;
scrollTop(): number;
static extend(...objects: any[]): any;
static inArray(value: any, array: any[], startIndex: number): number;
static isEmptyObject(object: any): boolean;
}
declare class Waypoint {
constructor(options: WaypointOptions);
// properties
adapter: WaypointAdapter;
context: WaypointContext;
element: HTMLElement;
group: WaypointGroup;
options: WaypointOptions;
triggerPoint: number;
// Instance Methods
destroy(): Waypoint;
disable(): Waypoint;
enable(): Waypoint;
next(): Waypoint | string; // actually `null` not string
previous(): Waypoint | string; // actually `null` not string
// Class Methods
static destroyAll(): void;
static disableAll(): void;
static enableAll(): void;
static refreshAll(): void;
static viewportHeight(): number;
static viewportWidth(): number;
static adapters: {
push: ({name: string, Adapter: WaypointAdapter})
};
static Adapter: WaypointAdapter;
// Waypoint.Context
static Context: {
findByElement(element: HTMLElement): WaypointContext|undefined;
};
}