How does WeChat Mini Programs judge that the element is in the visual area?

apart from the scroll-view component, what other way does WeChat Mini Programs have to know if the element is in the visual area?-sharp-sharp-sharp

Apr.08,2022

Mini Program is relatively simple:
the distance of the dom.top element from the top of the window notes that it changes as you scroll.
the height of the dom.height element.
height of the windowHeight window.

if the top of the element is within the window height range, it is proved to be in the visible area.
if (el.top < windowHeight & & top > 0) {can be judged}

be more rigorous and add the height of the element itself.

if (el.top < windowHeight & & el.top+el.height > 0) {

 

}

variables are obtained in two ways:

//
 var SystemInfo = wx.getSystemInfoSync()
  console.log(SystemInfo.windowHeight)
 // 
    var query = wx.createSelectorQuery();
    //id
    var that = this;
    query.select('-sharpyuyue').boundingClientRect(function (rect) {
       console.log(':'+rect.top)
Menu