code: function getElementTop(el) {
    let top = 0;
    let element = el;
  
    do {
      top += element.offsetTop || 0;
      element = element.offsetParent;
    } while (element);
  
    return top;
  }
docs: Get element's top offset