ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
78 lines (77 loc) • 2.55 kB
TypeScript
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
/**
* fit content details: https://github.com/NG-ZORRO/ng-zorro-antd/pull/6154#issuecomment-745025554
*
* calc position x,y point
*
* CASE (width <= clientWidth && height <= clientHeight):
*
* ------------- clientWidth -------------
* | |
* | ------ width ------ |
* | | | |
* | | | |
* client height | |
* Height | | |
* | | | |
* | ------------------- |
* | |
* | |
* ---------------------------------------
* fixedPosition = { x: 0, y: 0 }
*
*
*
* CASE (width > clientWidth || height > clientHeight):
*
* ------------- clientWidth -------------
* | | |
* | top |
* | | |
* |--left--|--------------- width -----------------
* | | |
* client | |
* Height | |
* | | |
* | | |
* | height |
* | | |
* ---------| |
* | |
* | |
* | |
* ----------------------------------------
*
*
* - left || top > 0
* left -> 0 || top -> 0
*
* - (left + width) < clientWidth || (top + height) < clientHeight
* - left | top + width | height < clientWidth | clientHeight -> Back left | top + width | height === clientWidth | clientHeight
*
* DEFAULT:
* - hold position
*
*/
export declare function getFitContentPosition(params: {
width: number;
height: number;
left: number;
top: number;
clientWidth: number;
clientHeight: number;
}): {
x?: number;
y?: number;
};
export declare function getOffset(node: HTMLElement): {
left: number;
top: number;
};
export declare function getClientSize(): {
width: number;
height: number;
};