<commit_before>import { Directive, ElementRef, Input, Output, EventEmitter, OnDestroy, OnInit, OnChanges, SimpleChanges, NgZone } from '@angular/core';
import { Scroller } from './scroller';
import { AxisResolver } from './axis-resolver';

@Directive({
  selector: '[infinite-scroll]'
})
export class InfiniteScroll implements OnDestroy, OnInit, OnChanges {
  public scroller: Scroller;

  @Input('infiniteScrollDistance') _distanceDown: number = 2;
  @Input('infiniteScrollUpDistance') _distanceUp: number = 1.5;
  @Input('infiniteScrollThrottle') _throttle: number = 300;
  @Input('infiniteScrollDisabled') _disabled: boolean = false;
  @Input('scrollWindow') scrollWindow: boolean = true;
  @Input('immediateCheck') _immediate: boolean = false;
  @Input('horizontal') _horizontal: boolean = false;
  @Input('alwaysCallback') _alwaysCallback: boolean = false;

  @Output() scrolled = new EventEmitter();
  @Output() scrolledUp = new EventEmitter();

  constructor(
    private element: ElementRef,
    private zone: NgZone,
    private axis: AxisResolver
  ) {}

  ngOnInit() {
    const containerElement = this.scrollWindow ? window : this.element;
    this.scroller = new Scroller(containerElement, setInterval, this.element,
        this.onScrollDown.bind(this), this.onScrollUp.bind(this),
        this._distanceDown, this._distanceUp, {}, this._throttle,
        this._immediate, this._horizontal, this._alwaysCallback,
        this._disabled, this.axis);
  }

  ngOnDestroy () {
    if (this.scroller) {
      this.scroller.clean();
    }
  }

  ngOnChanges(changes: SimpleChanges) {
    if(changes['_disabled'] && this.scroller){
      this.scroller.handleInfiniteScrollDisabled(changes['_disabled'].currentValue);
    }
  }
<commit_msg>only instantiate scroller in browser environment<commit_after>import { Directive, ElementRef, Input, Output, EventEmitter, OnDestroy, OnInit, OnChanges, SimpleChanges, NgZone } from '@angular/core';
import { Scroller } from './scroller';
import { AxisResolver } from './axis-resolver';

@Directive({
  selector: '[infinite-scroll]'
})
export class InfiniteScroll implements OnDestroy, OnInit, OnChanges {
  public scroller: Scroller;

  @Input('infiniteScrollDistance') _distanceDown: number = 2;
  @Input('infiniteScrollUpDistance') _distanceUp: number = 1.5;
  @Input('infiniteScrollThrottle') _throttle: number = 300;
  @Input('infiniteScrollDisabled') _disabled: boolean = false;
  @Input('scrollWindow') scrollWindow: boolean = true;
  @Input('immediateCheck') _immediate: boolean = false;
  @Input('horizontal') _horizontal: boolean = false;
  @Input('alwaysCallback') _alwaysCallback: boolean = false;

  @Output() scrolled = new EventEmitter();
  @Output() scrolledUp = new EventEmitter();

  constructor(
    private element: ElementRef,
    private zone: NgZone,
    private axis: AxisResolver
  ) {}

  ngOnInit() {
    if (typeof window !== 'undefined') {
      const containerElement = this.scrollWindow ? window : this.element;
      this.scroller = new Scroller(containerElement, setInterval, this.element,
          this.onScrollDown.bind(this), this.onScrollUp.bind(this),
          this._distanceDown, this._distanceUp, {}, this._throttle,
          this._immediate, this._horizontal, this._alwaysCallback,
          this._disabled, this.axis);
    }
  }

  ngOnDestroy () {
    if (this.scroller) {
      this.scroller.clean();
    }
  }

  ngOnChanges(changes: SimpleChanges) {
    if(changes['_disabled'] && this.scroller){
      this.scroller.handleInfiniteScrollDisabled(changes['_disabled'].currentValue);
    }
  }

{'fraction_non_alphanumeric': 0.1279977691020636, 'fraction_numerical': 0.0033463469046291134, 'mean_word_length': 4.526964560862866, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6401001', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1049, 'n_words': 237}