pixelRound

Commons
stable

Round a sub-pixel value to the nearest physical pixel boundary using `devicePixelRatio`. Prevents blurry rendering on high-DPI screens when positioning overlays and tooltips.

API

Signature

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

Paramètres d'entrée acceptés par cet util.

val
requis
number
A CSS pixel value (fractional or whole). Multiplied by `devicePixelRatio`, rounded, then divided back to the nearest physical-pixel boundary.

API

Valeur de retour

La valeur retournée par cet util.

The input rounded to the nearest physical pixel grid line in CSS pixel units.

Usage

Exemples

Extraits de code prêts à coller.

Round to physical pixel (2x display)

typescript