'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var isHTMLElement = _interopDefault(require('./isHTMLElement'));

/**
 * 获取页面滚动位置
 * @param {HTMLElement} element
 * @returns {{scrollLeft: number, scrollTop: number}}
 */
function getScrollPosition(element) {
  if (isHTMLElement(element)) {
    return {
      scrollLeft: element.scrollLeft,
      scrollTop: element.scrollTop
    };
  }

  var de = document.documentElement;
  var db = document.body;
  return {
    scrollLeft: de.scrollLeft || db.scrollLeft,
    scrollTop: de.scrollTop || db.scrollTop
  };
}

module.exports = getScrollPosition;
