apphouse
Version:
Component library for React that uses observable state management and theme-able components.
38 lines (33 loc) • 1.03 kB
TypeScript
export interface TooltipPosition {
top: number;
left: number;
}
export interface TooltipDimensions {
width: number;
height: number;
}
/**
*
* Function to calculate best position for tooltip
* Usage Example
const tooltipContentWidth = 200;
const tooltipContentHeight = 100;
// Mocking tooltip width and height
const tooltipDimensions: TooltipDimensions = {
width: tooltipContentWidth + 20, // Add extra space for padding or border
height: tooltipContentHeight + 20
};
const tooltipPosition: TooltipPosition = calculateTooltipPosition(
tooltipDimensions.width,
tooltipDimensions.height,
tooltipContentWidth,
tooltipContentHeight
);
console.log('Tooltip position:', tooltipPosition);
* @param tooltipWidth
* @param tooltipHeight
* @param tooltipContentWidth
* @param tooltipContentHeight
* @returns TooltipPosition
*/
export declare function calculateTooltipPosition(tooltipWidth: number, tooltipHeight: number, tooltipContentWidth: number, tooltipContentHeight: number): TooltipPosition;