# NodesRef.boundingClientRect

Call NodesRef.boundingClientRect(function callback) to add a query request for the node layout position. Relative to the display area, measured in pixels. Its function is similar to DOM's `getBoundingClientRect`. Returns the `SelectorQuery` corresponding to `nodesRef`. If a `callback` callback function is provided, the node information will be returned in `callback` after executing the `selectQuery.exec` method.

## Support

This API only supports gadget calls, and the corresponding client version support is as follows.

App capability | Android | iOS | PC | Harmony | Preview
---|---|---|---|---|---
Gadget | V2.2.0+ | V2.2.0+ | V2.2.0+ | V7.35.0+ | Preview
Web app | **X** | **X** | **X** | **X** | /

## Input

Name | Data type | Required | Default value | Description
---|---|---|---|---
callback | function | Yes | \- | Callback function of this event.

## Output

The properties of the object returned by the callback function are as follows.

Name | Data type | Description
---|---|---
id | string | Node ID.
dataset | object | Node dataset.
left | number | Coordinates of the node's left boundary.
right | number | Coordinates of the node's right boundary.
top | number | Coordinates of the node's top boundary.
bottom | number | Coordinates of the node's bottom boundary.
width | number | Node width.
height | number | Node height.

##  Sample code

```js
Page({
  getRect () {
    tt.createSelectorQuery().select('#the-id').boundingClientRect(function(rect){
      rect.id      // Node ID
      rect.dataset // Node dataset
      rect.left    // Coordinates of the node's left boundary
      rect.right   // Coordinates of the node's right boundary
      rect.top     // Coordinates of the node's top boundary
      rect.bottom  // Coordinates of the node's bottom boundary
      rect.width   // Node width
      rect.height  // Node height
    }).exec()
  },
  getAllRects () {
    tt.createSelectorQuery().selectAll('.class-name').boundingClientRect(function(rects){
      rects.forEach(function(rect){
        rect.id      // Node ID
        rect.dataset // Node dataset
        rect.left    // Coordinates of the node's left boundary
        rect.right   // Coordinates of the node's right boundary
        rect.top     // Coordinates of the node's top boundary
        rect.bottom  // Coordinates of the node's bottom boundary
        rect.width   // Node width
        rect.height  // Node height
      })
    }).exec()
  }
})
```
