import * as tslib_1 from "tslib";
import { Component, ElementRef, ViewEncapsulation, ChangeDetectionStrategy, NgZone } from '@angular/core';
var InkBarComponent = /** @class */ (function () {
    function InkBarComponent(_elementRef, _ngZone) {
        this._elementRef = _elementRef;
        this._ngZone = _ngZone;
    }
    /**
     * Calculates the styles from the provided element in order to align the ink-bar to that element.
     * Shows the ink bar if previously set as hidden.
     * @param element
     */
    InkBarComponent.prototype.alignToElement = function (element) {
        var _this = this;
        this.show();
        if (typeof requestAnimationFrame !== 'undefined') {
            this._ngZone.runOutsideAngular(function () {
                requestAnimationFrame(function () { return _this._setStyles(element); });
            });
        }
        else {
            this._setStyles(element);
        }
    };
    /** Shows the ink bar. */
    InkBarComponent.prototype.show = function () {
        this._elementRef.nativeElement.style.visibility = 'visible';
    };
    /** Hides the ink bar. */
    InkBarComponent.prototype.hide = function () {
        this._elementRef.nativeElement.style.visibility = 'hidden';
    };
    /**
     * Sets the proper styles to the ink bar element.
     * @param element
     */
    InkBarComponent.prototype._setStyles = function (element) {
        var inkBar = this._elementRef.nativeElement;
        inkBar.style.left = element ? (element.offsetLeft || 0) + 'px' : '0';
        inkBar.style.width = element ? (element.offsetWidth || 0) + 'px' : '0';
    };
    InkBarComponent = tslib_1.__decorate([
        Component({
            selector: 'nb-ink-bar',
            template: '',
            encapsulation: ViewEncapsulation.None,
            changeDetection: ChangeDetectionStrategy.OnPush,
            preserveWhitespaces: false,
            host: {
                'class': 'nb-widget nb-ink-bar'
            },
            exportAs: 'nbInkBar'
        }),
        tslib_1.__metadata("design:paramtypes", [ElementRef,
            NgZone])
    ], InkBarComponent);
    return InkBarComponent;
}());
export { InkBarComponent };
//# sourceMappingURL=ink-bar.js.map