<commit_before>import { ElementRef } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import { AxisResolver } from './axis-resolver';
import 'rxjs/add/observable/fromEvent';
import 'rxjs/add/observable/timer';
import 'rxjs/add/operator/throttle';

export class Scroller {
	public scrollDownDistance: number;
	public scrollUpDistance: number;
	public scrollEnabled: boolean;
	public checkWhenEnabled: boolean;
	public container: Window | ElementRef | any;
	public immediateCheck: boolean;
	public useDocumentBottom: boolean;
	public checkInterval: number;
	private documentElement: Window | ElementRef | any;
	private isContainerWindow: boolean;
	private disposeScroll: Subscription;
	public lastScrollPosition: number = 0;
	private axis: AxisResolver;

	constructor(
		private windowElement: Window | ElementRef | any,
		private $interval: Function,
		private $elementRef: ElementRef,
		private infiniteScrollDownCallback: Function,
		private infiniteScrollUpCallback: Function,
		infiniteScrollDownDistance: number,
		infiniteScrollUpDistance: number,
		infiniteScrollParent: Window | ElementRef | any,
		private infiniteScrollThrottle: number,
		private isImmediate: boolean,
		private horizontal: boolean = false,
		private alwaysCallback: boolean = false
	) {
		this.isContainerWindow = toString.call(this.windowElement).includes('Window');
		this.documentElement = this.isContainerWindow ? this.windowElement.document.documentElement : null;
		this.handleInfiniteScrollDistance(infiniteScrollDownDistance, infiniteScrollUpDistance);

		// if (attrs.infiniteScrollParent != null) {
		// 	attachEvent(angular.element(elem.parent()));
		// }
		this.handleInfiniteScrollDisabled(false);
		this.defineContainer();
		this.createInterval();
		this.axis = new AxisResolver(!this.horizontal);
	}

	defineContainer () {
		if (this.isContainerWindow) {
			this.container = this.windowElement;
		} else {
			this.container = this.windowElement.nativeElement;
		}
		this.attachEvent(this.container);
	}

	createInterval () {
		if (this.isImmediate) {
			this.checkInterval = this.$interval(() => {
				return this.handler();
			}, 0);<commit_msg>fixes #61<commit_after>import { ElementRef } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import { AxisResolver } from './axis-resolver';
import 'rxjs/add/observable/fromEvent';
import 'rxjs/add/observable/timer';
import 'rxjs/add/operator/throttle';

export class Scroller {
	public scrollDownDistance: number;
	public scrollUpDistance: number;
	public scrollEnabled: boolean;
	public checkWhenEnabled: boolean;
	public container: Window | ElementRef | any;
	public immediateCheck: boolean;
	public useDocumentBottom: boolean;
	public checkInterval: number;
	private documentElement: Window | ElementRef | any;
	private isContainerWindow: boolean;
	private disposeScroll: Subscription;
	public lastScrollPosition: number = 0;
	private axis: AxisResolver;

	constructor(
		private windowElement: Window | ElementRef | any,
		private $interval: Function,
		private $elementRef: ElementRef,
		private infiniteScrollDownCallback: Function,
		private infiniteScrollUpCallback: Function,
		infiniteScrollDownDistance: number,
		infiniteScrollUpDistance: number,
		infiniteScrollParent: Window | ElementRef | any,
		private infiniteScrollThrottle: number,
		private isImmediate: boolean,
		private horizontal: boolean = false,
		private alwaysCallback: boolean = false
	) {
		this.isContainerWindow = Object.prototype.toString.call(this.windowElement).includes('Window');
		this.documentElement = this.isContainerWindow ? this.windowElement.document.documentElement : null;
		this.handleInfiniteScrollDistance(infiniteScrollDownDistance, infiniteScrollUpDistance);

		// if (attrs.infiniteScrollParent != null) {
		// 	attachEvent(angular.element(elem.parent()));
		// }
		this.handleInfiniteScrollDisabled(false);
		this.defineContainer();
		this.createInterval();
		this.axis = new AxisResolver(!this.horizontal);
	}

	defineContainer () {
		if (this.isContainerWindow) {
			this.container = this.windowElement;
		} else {
			this.container = this.windowElement.nativeElement;
		}
		this.attachEvent(this.container);
	}

	createInterval () {
		if (this.isImmediate) {
			this.checkInterval = this.$interval(() => {
				return this.handler();
			}, 0);
{'fraction_non_alphanumeric': 0.10548904449966116, 'fraction_numerical': 0.0013553196295459679, 'mean_word_length': 5.492668621700879, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6563370', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1238, 'n_words': 288}