NodesRef.boundingClientRect
Introduction
Adds a query request for the layout position of a node relative to the display area (unit: pixels). It functions similarly to getBoundingClientRect
in the DOM. The return value is the selectorQuery
corresponding to the nodesRef
.
Parameters
Function callback
Explanation of callback return parameters
In the returned node information, the position of each node is described by the fields left
, right
, top
, bottom
, width
, and height
. If a callback function is provided, after executing the exec
method of selectQuery
, the node information will be returned in the callback.
Parameter | Type | Description |
---|---|---|
left | Number | Node's left boundary coordinate |
right | Number | Node's right boundary coordinate |
top | Number | Node's top boundary coordinate |
bottom | Number | Node's bottom boundary coordinate |
width | Number | Node's width |
height | Number | Node's height |
Sample Code
Page({
queryNodeInfo() {
dlt
.createSelectorQuery()
.select('.target')
.boundingClientRect((rect) => {
console.log('Node Information', rect);
})
.exec();
},
});