|
|
declare namespace place {
|
|
|
interface PlacePosition {
|
|
|
x: number;
|
|
|
y: number;
|
|
|
}
|
|
|
|
|
|
interface PlaceWidthHeight {
|
|
|
w: number;
|
|
|
h: number;
|
|
|
}
|
|
|
|
|
|
interface PlaceRectangle extends PlacePosition, PlaceWidthHeight { }
|
|
|
|
|
|
type PlaceCorner = 'BL' | 'TR' | 'BR' | 'TL';
|
|
|
|
|
|
type PlacePositions = 'before' | 'after' | 'before-centered' | 'after-centered' | 'above-centered' | 'above' | 'above-alt' | 'below-centered' | 'below' | 'below-alt';
|
|
|
|
|
|
interface PlaceChoice {
|
|
|
corner: PlaceCorner;
|
|
|
pos: PlacePosition;
|
|
|
aroundCorner?: PlaceCorner;
|
|
|
}
|
|
|
|
|
|
interface PlaceLocation extends PlaceRectangle {
|
|
|
corner: PlaceCorner;
|
|
|
aroundCorner: PlaceCorner;
|
|
|
overflow: number;
|
|
|
spaceAvailable: PlaceWidthHeight;
|
|
|
}
|
|
|
|
|
|
interface LayoutNodeFunction {
|
|
|
(node: HTMLElement, aroundCorner: string, corner: string, spaceAvailable: PlaceWidthHeight, aroundNodeCoords: PlaceWidthHeight): number;
|
|
|
}
|
|
|
|
|
|
interface Place {
|
|
|
/**
|
|
|
* Positions node kitty-corner to the rectangle centered at (pos.x, pos.y) with width and height of
|
|
|
* padding.x * 2 and padding.y * 2, or zero if padding not specified. Picks first corner in corners[]
|
|
|
* where node is fully visible, or the corner where it's most visible.
|
|
|
*
|
|
|
* Node is assumed to be absolutely or relatively positioned.
|
|
|
*/
|
|
|
at(node: Element, pos?: PlacePosition, corners?: PlaceCorner[], padding?: PlacePosition, layoutNode?: LayoutNodeFunction): PlaceLocation;
|
|
|
|
|
|
/**
|
|
|
* Position node adjacent or kitty-corner to anchor
|
|
|
* such that it's fully visible in viewport.
|
|
|
*/
|
|
|
around(node: Element, anchor: Element | PlaceRectangle, positions: PlacePositions[], leftToRight?: boolean, layoutNode?: LayoutNodeFunction): PlaceLocation;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
declare const place: place.Place;
|
|
|
export = place;
|
|
|
|