Add tether typings

This commit is contained in:
Adi Dahiya
2015-03-04 20:56:23 -05:00
parent fe39944e4d
commit 68ae7bb60d
2 changed files with 103 additions and 0 deletions

53
tether/tether-tests.ts Normal file
View File

@@ -0,0 +1,53 @@
///<reference path="../jquery/jquery.d.ts" />
///<reference path="tether.d.ts" />
var yellowBox = document.querySelector(".yellow");
var greenBox = document.querySelector(".green");
new Tether({
attachment: "bottom middle",
targetAttachment: "top middle",
targetModifier: "visible",
offset: "-15px 0",
targetOffset: "0 0"
});
new Tether({
element: yellowBox,
target: greenBox,
attachment: "top left",
optimizations: {
gpu: false
}
});
new Tether({
element: yellowBox,
target: greenBox,
attachment: "top left",
targetAttachment: "bottom left",
constraints: [
{
to: "scrollParent",
pin: true
},
{
to: "window",
attachment: "together"
}
]
});
new Tether({
element: yellowBox,
target: greenBox,
attachment: "middle left",
targetAttachment: "middle left",
constraints: [
{
to: "scrollParent",
pin: ["top"]
}
]
});

50
tether/tether.d.ts vendored Normal file
View File

@@ -0,0 +1,50 @@
// Type definitions for Tether v0.6
// Project: http://github.hubspot.com/tether/
// Definitions by: Adi Dahiya <https://github.com/adidahiya>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module tether {
interface TetherStatic {
new(options: ITetherOptions): Tether;
}
interface ITetherOptions {
attachment?: string;
classes?: {[className: string]: boolean};
classPrefix?: string;
constraints?: ITetherConstraint[];
element?: Element | string | any /* JQuery */;
enabled?: boolean;
offset?: string;
optimizations?: any;
target?: Element | string | any /* JQuery */;
targetAttachment?: string;
targetOffset?: string;
targetModifier?: string;
}
interface ITetherConstraint {
attachment?: string;
outOfBoundsClass?: string;
pin?: boolean | string[];
pinnedClass?: string;
to?: string | Element | number[];
}
interface Tether {
setOptions(options: ITetherOptions): void;
disable(): void;
enable(): void;
destroy(): void;
position(): void;
}
}
declare module "tether" {
export = tether;
}
declare var Tether: tether.TetherStatic;