code: function getRect(el) {
    if (el && typeof(el.getBoundingClientRect) === 'function') {
      return el.getBoundingClientRect();
    }
  
    if (el === window || el === document) {
      return {top: 0, left: 0, bottom: window.innerHeight, height: window.innerHeight, width: window.innerWidth, right: window.innerWidth};
    }
  
    return {top: 0, left: 0, right: 0, bottom: 0, width: 0, height: 0};
  }
docs: some helpers