@kvaser/canking-api
Version:
CanKing API to communicate with the CanKing service using Node.js.
23 lines (22 loc) • 1.09 kB
TypeScript
/**
* Utility functions for ToolbarControl overflow calculation.
*
* @packageDocumentation
*/
/**
* Calculates the first item index that should collapse into an overflow menu.
*
* Uses a two-pass algorithm:
* 1. Check whether all items fit without an overflow button.
* 2. If they don't, re-fit as many items as possible while reserving space for the overflow button.
*
* Returns `itemCount` when all items fit (no overflow).
*
* @param itemCount - Total number of toolbar items.
* @param containerSize - Available size of the toolbar container (width for horizontal, height for vertical).
* @param itemSizes - Measured sizes of each toolbar item along the same axis. Must have `itemCount` entries.
* @param overflowButtonSize - Size of the overflow button that appears when overflow occurs.
* @returns The index of the first item that moves to the overflow menu, or `itemCount` when there is no overflow.
* @internal
*/
export declare function calculateOverflowStartIndex(itemCount: number, containerSize: number, itemSizes: number[], overflowButtonSize: number): number;