uvue.uts 540 B

1234567891011121314151617
  1. export function getRect(selector : string, context: ComponentInternalInstance):Promise<NodeInfo> {
  2. return new Promise((resolve,)=>{
  3. uni.createSelectorQuery().in(context).select(selector).boundingClientRect(res =>{
  4. resolve(res as NodeInfo)
  5. }).exec();
  6. })
  7. }
  8. export function getAllRect(selector : string, context: ComponentInternalInstance):Promise<NodeInfo[]> {
  9. return new Promise((resolve,)=>{
  10. uni.createSelectorQuery().in(context).selectAll(selector).boundingClientRect(res =>{
  11. resolve(res as NodeInfo[])
  12. }).exec();
  13. })
  14. }