getOverflow

Commons
stable

Calculates how much box a overflows box b on each side (before/after on both axes). Returns zero for sides where a is fully contained inside b.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

a
required
IBox
The potentially overflowing box (e.g. a floating overlay or tooltip).
b
required
IBox
The bounding container box (e.g. the viewport or a scroll container).

API

Return value

The value returned by this util.

An object with x and y axes, each containing before (left/top overflow) and after (right/bottom overflow) amounts in pixels. Values are ≥ 0.

Usage

Examples

Ready-to-paste usage snippets.

Check if a tooltip overflows the viewport

typescript