import * as O from 'fp-ts/lib/Option';
export class ViewService {
  set topElement(url) {
    this._topElement = O.fromNullable(url);
  }
  get topElement() {
    if (O.isNone(this._topElement)) {
      throw Error('Top element is not set');
    }
    return this._topElement.value;
  }
  scrollToTop() {
    window.scrollBy({ top: this.topElement.getBoundingClientRect().y, behavior: 'smooth' });
  }
}
export default new ViewService();
