clampTarget
Commons
stable
Clamps a scroll target value to the valid scroll range of a container element, supporting both vertical and horizontal axes. Used internally by the goTo scroll utility.
API
Signature
Signature TypeScript complète, extraite du fichier util.
API
Paramètres
Paramètres d'entrée acceptés par cet util.
- containerrequisHTMLElement
- The scrollable container whose scroll range is used as bounds.
- valuerequisnumber
- The desired scroll position in pixels.
- horizontalrequisboolean
- When true, clamps against the horizontal scroll range; otherwise the vertical range.
API
Valeur de retour
La valeur retournée par cet util.
- The clamped scroll position between 0 and the maximum scrollable distance of the container.
Usage
Exemples
Extraits de code prêts à coller.
Prevent over-scrolling