# SelectorQuery NodesRef.boundingClientRect(function callback)

with Promise style call: Not supported

Mini Program plugin: Support

Add a query request for the layout location of the node. In pixels relative to the display area. Its function is similar to HOUSE of getBoundingClientRectReturn. NodesRef Corresponding SelectorQuery

# parameter

# function callback

Callback function, before executing SelectorQuery.exec Method, the node information is displayed in the callback Returns in.

# parameter

# Object res
attribute type Introductions
id string Node ID
dataset Object Node dataset
left number Left boundary coordinates of nodes
right number Node's right boundary coordinates
top number Upper boundary coordinates of nodes
bottom number Lower boundary coordinates of nodes
width number Width of node
height number Node height

# Return value

# SelectorQuery

# sample code

Page({
  getRect () {
    wx.createSelectorQuery().select('#the-id').boundingClientRect(function(rect){
      rect.id      // Node ID
      rect.dataset // DataSet for Node
      rect.left    // Left boundary coordinates of nodes
      rect.right   // Node's right boundary coordinates
      rect.top     // Upper boundary coordinates of nodes
      rect.bottom  // Lower boundary coordinates of nodes
      rect.width   // Width of node
      rect.height  // Node height
    }).exec()
  },
  getAllRects () {
    wx.createSelectorQuery().selectAll('.a-class').boundingClientRect(function(rects){
      rects.forEach(function(rect){
        rect.id      // Node ID
        rect.dataset // DataSet for Node
        rect.left    // Left boundary coordinates of nodes
        rect.right   // Node's right boundary coordinates
        rect.top     // Upper boundary coordinates of nodes
        rect.bottom  // Lower boundary coordinates of nodes
        rect.width   // Width of node
        rect.height  // Node height
      })
    }).exec()
  }
})