code: function getOffset(el) {
    var rect = el.getBoundingClientRect();
    var scroll = getScroll();
    return {
      x: rect.left + scroll.left,
      y: rect.top + scroll.top
    };
  }
docs: refer: https://gist.github.com/aderaaij/89547e34617b95ac29d1