Function: getScrollPercentage()
ts
function getScrollPercentage(target?): number;Calculates the scroll progress percentage for an element or the window.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
target | HTMLElement | Window | window | The scroll container. Defaults to window. |
Returns
number
The scroll percentage between 0 and 100.
Example
ts
getScrollPercentage(document.documentElement)
// => 45Since
1.0.0