import isHTMLElement from './isHTMLElement';
import scrollTo from './scrollTo';
import getPageSize from './getPageSize';

/**
 * 滚动到页面底部
 * @param {Object} options
 *
 * scrollToBottom();
 * scrollToBottom({ animation: false });
 * scrollToBottom({ element: document.querySelector('#container') });
 */
function scrollToBottom(options) {
  options = options || {};
  var element = isHTMLElement(options.element) ? options.element : null;
  var scrollHeight = element ? element.scrollHeight : getPageSize().pageHeight;
  scrollTo(scrollHeight, options);
}

export default scrollToBottom;
