UNPKG

@sparkpost/matchbox

Version:
53 lines (52 loc) 1.68 kB
import React from 'react'; export declare type WindowRect = { top: number; left: number; height: number; width: number; }; export declare function getWindowRect(): WindowRect; export declare function getRectFor(node?: React.ReactInstance): ClientRect; /** * Provides a hook that returns window dimensions * @param {number} [wait=100] Timer for debounced dimension calculation * @return {Shape} Same results as `getWindowRect`` */ export declare function useWindowSize(wait?: number): WindowRect; /** * Gets preferred direction for the provided react component * @param {React Node} node - a react component * @return {Shape} * Returns directional booleans for where the component should render. Eg: * top: true if component is in the bottom half of the screen * right: true if component in the left half of the screen */ export declare function getPreferredDirectionFor(node?: React.ReactInstance): { top: boolean; left: boolean; right: boolean; bottom: boolean; }; /** * Gets coordinates and dimensions in pixels for the provided react component * @param {React Node} node * @return {Shape} */ export declare function getPositionFor(node?: React.ReactInstance, { fixed }?: { fixed?: boolean; }): WindowRect; /** * Linearly interpolates and clamps between two values * @param {number} min * @param {number} max * @param {number} n * @return {number} * @example * lerp(10, 20, 0.5) * > 15 */ export declare function lerp(min: number, max: number, n: number): number; /** * Rounds a number to the nearest baseline ceiling */ export declare function roundToBaseline(n: number, base?: number): number;