source: trip-planner-front/node_modules/@angular/material/esm2015/tabs/ink-bar.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 9.3 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { Directive, ElementRef, Inject, InjectionToken, NgZone, Optional } from '@angular/core';
9import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
10/** Injection token for the MatInkBar's Positioner. */
11export const _MAT_INK_BAR_POSITIONER = new InjectionToken('MatInkBarPositioner', {
12 providedIn: 'root',
13 factory: _MAT_INK_BAR_POSITIONER_FACTORY
14});
15/**
16 * The default positioner function for the MatInkBar.
17 * @docs-private
18 */
19export function _MAT_INK_BAR_POSITIONER_FACTORY() {
20 const method = (element) => ({
21 left: element ? (element.offsetLeft || 0) + 'px' : '0',
22 width: element ? (element.offsetWidth || 0) + 'px' : '0',
23 });
24 return method;
25}
26/**
27 * The ink-bar is used to display and animate the line underneath the current active tab label.
28 * @docs-private
29 */
30export class MatInkBar {
31 constructor(_elementRef, _ngZone, _inkBarPositioner, _animationMode) {
32 this._elementRef = _elementRef;
33 this._ngZone = _ngZone;
34 this._inkBarPositioner = _inkBarPositioner;
35 this._animationMode = _animationMode;
36 }
37 /**
38 * Calculates the styles from the provided element in order to align the ink-bar to that element.
39 * Shows the ink bar if previously set as hidden.
40 * @param element
41 */
42 alignToElement(element) {
43 this.show();
44 if (typeof requestAnimationFrame !== 'undefined') {
45 this._ngZone.runOutsideAngular(() => {
46 requestAnimationFrame(() => this._setStyles(element));
47 });
48 }
49 else {
50 this._setStyles(element);
51 }
52 }
53 /** Shows the ink bar. */
54 show() {
55 this._elementRef.nativeElement.style.visibility = 'visible';
56 }
57 /** Hides the ink bar. */
58 hide() {
59 this._elementRef.nativeElement.style.visibility = 'hidden';
60 }
61 /**
62 * Sets the proper styles to the ink bar element.
63 * @param element
64 */
65 _setStyles(element) {
66 const positions = this._inkBarPositioner(element);
67 const inkBar = this._elementRef.nativeElement;
68 inkBar.style.left = positions.left;
69 inkBar.style.width = positions.width;
70 }
71}
72MatInkBar.decorators = [
73 { type: Directive, args: [{
74 selector: 'mat-ink-bar',
75 host: {
76 'class': 'mat-ink-bar',
77 '[class._mat-animation-noopable]': `_animationMode === 'NoopAnimations'`,
78 },
79 },] }
80];
81MatInkBar.ctorParameters = () => [
82 { type: ElementRef },
83 { type: NgZone },
84 { type: undefined, decorators: [{ type: Inject, args: [_MAT_INK_BAR_POSITIONER,] }] },
85 { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
86];
87//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5rLWJhci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC90YWJzL2luay1iYXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLFNBQVMsRUFBRSxVQUFVLEVBQUUsTUFBTSxFQUFFLGNBQWMsRUFBRSxNQUFNLEVBQUUsUUFBUSxFQUFDLE1BQU0sZUFBZSxDQUFDO0FBQzlGLE9BQU8sRUFBQyxxQkFBcUIsRUFBQyxNQUFNLHNDQUFzQyxDQUFDO0FBVzNFLHNEQUFzRDtBQUN0RCxNQUFNLENBQUMsTUFBTSx1QkFBdUIsR0FDbEMsSUFBSSxjQUFjLENBQXVCLHFCQUFxQixFQUFFO0lBQzlELFVBQVUsRUFBRSxNQUFNO0lBQ2xCLE9BQU8sRUFBRSwrQkFBK0I7Q0FDekMsQ0FBQyxDQUFDO0FBRUw7OztHQUdHO0FBQ0gsTUFBTSxVQUFVLCtCQUErQjtJQUM3QyxNQUFNLE1BQU0sR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sZW1lbnQuc3R5bGUudmlzaWJpbGl0eSA9ICdoaWRkZW4nO1xuICB9XG5cbiAgLyoqXG4gICAqIFNldHMgdGhlIHByb3BlciBzdHlsZXMgdG8gdGhlIGluayBiYXIgZWxlbWVudC5cbiAgICogQHBhcmFtIGVsZW1lbnRcbiAgICovXG4gIHByaXZhdGUgX3NldFN0eWxlcyhlbGVtZW50OiBIVE1MRWxlbWVudCkge1xuICAgIGNvbnN0IHBvc2l0aW9ucyA9IHRoaXMuX2lua0JhclBvc2l0aW9uZXIoZWxlbWVudCk7XG4gICAgY29uc3QgaW5rQmFyOiBIVE1MRWxlbWVudCA9IHRoaXMuX2VsZW1lbnRSZWYubmF0aXZlRWxlbWVudDtcblxuICAgIGlua0Jhci5zdHlsZS5sZWZ0ID0gcG9zaXRpb25zLmxlZnQ7XG4gICAgaW5rQmFyLnN0eWxlLndpZHRoID0gcG9zaXRpb25zLndpZHRoO1xuICB9XG59XG4iXX0=
Note: See TracBrowser for help on using the repository browser.