Skip to content

Function: getBoundingClientPosition()

ts
function getBoundingClientPosition(ele): ClientXY;

Gets the client (x, y) coordinates of the specified element relative to the viewport.

Parameters

ParameterTypeDescription
eleHTMLElementThe element to get the bounding client for.

Returns

ClientXY

The client (x, y) coordinates of the element.

Example

ts
const el = document.createElement('div')
document.body.appendChild(el)
const bounds = getBoundingClientPosition(el)
bounds // => { x: 0, y: 0 }

Since

1.0.0

Released under the MIT License.