import { isWindow } from './getScrollHeight';
/**
 * @description 滚动的函数
 * @param options 滚动的配置参数
 * */

export function scrollTo(options) {
  var _options$getContainer = options.getContainer,
      getContainer = _options$getContainer === void 0 ? function () {
    return Window;
  } : _options$getContainer,
      callBack = options.callBack,
      _options$position = options.position,
      position = _options$position === void 0 ? 0 : _options$position;
  var container = getContainer();

  if (isWindow(container)) {
    container.scrollTo(0, 0);
  } else if (container instanceof Document) {
    container.documentElement.scrollTop = position;
  } else {
    container.scrollTop = position;
  }

  if (typeof callBack === 'function') {
    callBack();
  }
}