import { Directive, ElementRef, Output, EventEmitter, Renderer, HostListener } from '@angular/core';
var InfiniteScrollDirective = (function () {
    function InfiniteScrollDirective(_elementRef, _renderer) {
        this._elementRef = _elementRef;
        this._renderer = _renderer;
        this.docHeight = 0;
        this.scrolled = new EventEmitter();
        this.docHeight = this.getDocHeight();
    }
    InfiniteScrollDirective.prototype.track = function (event) {
        var currentDocHeight = this.getDocHeight();
        // console.log(currentDocHeight);
        // console.log(this.docHeight);
        if (currentDocHeight > (this.docHeight + 300)) {
            this.scrolled.emit({});
            this.docHeight = currentDocHeight;
        }
    };
    InfiniteScrollDirective.prototype.getDocHeight = function () {
        var D = document;
        return Math.max(D.body.scrollHeight, D.documentElement.scrollHeight, D.body.offsetHeight, D.documentElement.offsetHeight, D.body.clientHeight, D.documentElement.clientHeight);
    };
    InfiniteScrollDirective.decorators = [
        { type: Directive, args: [{
                    selector: '[infinite-scroll]'
                },] },
    ];
    /** @nocollapse */
    InfiniteScrollDirective.ctorParameters = function () { return [
        { type: ElementRef, },
        { type: Renderer, },
    ]; };
    InfiniteScrollDirective.propDecorators = {
        'scrolled': [{ type: Output },],
        'track': [{ type: HostListener, args: ['window:scroll', ['$event'],] },],
    };
    return InfiniteScrollDirective;
}());
export { InfiniteScrollDirective };
//# sourceMappingURL=infinite-scroll.directive.js.map