You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
435 lines
36 KiB
435 lines
36 KiB
import { InjectionToken, Component, ChangeDetectionStrategy, ViewEncapsulation, ElementRef, Optional, Inject, Input, NgModule } from '@angular/core';
|
|
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
import { mixinColor, MatCommonModule } from '@angular/material/core';
|
|
import { coerceNumberProperty } from '@angular/cdk/coercion';
|
|
import { _getShadowRoot, Platform } from '@angular/cdk/platform';
|
|
import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
|
|
|
|
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
/**
|
|
* Base reference size of the spinner.
|
|
* @docs-private
|
|
*/
|
|
import * as ɵngcc0 from '@angular/core';
|
|
import * as ɵngcc1 from '@angular/cdk/platform';
|
|
import * as ɵngcc2 from '@angular/common';
|
|
|
|
function MatProgressSpinner__svg_circle_1_Template(rf, ctx) { if (rf & 1) {
|
|
ɵngcc0.ɵɵnamespaceSVG();
|
|
ɵngcc0.ɵɵelement(0, "circle", 3);
|
|
} if (rf & 2) {
|
|
const ctx_r0 = ɵngcc0.ɵɵnextContext();
|
|
ɵngcc0.ɵɵstyleProp("animation-name", "mat-progress-spinner-stroke-rotate-" + ctx_r0._spinnerAnimationLabel)("stroke-dashoffset", ctx_r0._getStrokeDashOffset(), "px")("stroke-dasharray", ctx_r0._getStrokeCircumference(), "px")("stroke-width", ctx_r0._getCircleStrokeWidth(), "%");
|
|
ɵngcc0.ɵɵattribute("r", ctx_r0._getCircleRadius());
|
|
} }
|
|
function MatProgressSpinner__svg_circle_2_Template(rf, ctx) { if (rf & 1) {
|
|
ɵngcc0.ɵɵnamespaceSVG();
|
|
ɵngcc0.ɵɵelement(0, "circle", 3);
|
|
} if (rf & 2) {
|
|
const ctx_r1 = ɵngcc0.ɵɵnextContext();
|
|
ɵngcc0.ɵɵstyleProp("stroke-dashoffset", ctx_r1._getStrokeDashOffset(), "px")("stroke-dasharray", ctx_r1._getStrokeCircumference(), "px")("stroke-width", ctx_r1._getCircleStrokeWidth(), "%");
|
|
ɵngcc0.ɵɵattribute("r", ctx_r1._getCircleRadius());
|
|
} }
|
|
function MatSpinner__svg_circle_1_Template(rf, ctx) { if (rf & 1) {
|
|
ɵngcc0.ɵɵnamespaceSVG();
|
|
ɵngcc0.ɵɵelement(0, "circle", 3);
|
|
} if (rf & 2) {
|
|
const ctx_r0 = ɵngcc0.ɵɵnextContext();
|
|
ɵngcc0.ɵɵstyleProp("animation-name", "mat-progress-spinner-stroke-rotate-" + ctx_r0._spinnerAnimationLabel)("stroke-dashoffset", ctx_r0._getStrokeDashOffset(), "px")("stroke-dasharray", ctx_r0._getStrokeCircumference(), "px")("stroke-width", ctx_r0._getCircleStrokeWidth(), "%");
|
|
ɵngcc0.ɵɵattribute("r", ctx_r0._getCircleRadius());
|
|
} }
|
|
function MatSpinner__svg_circle_2_Template(rf, ctx) { if (rf & 1) {
|
|
ɵngcc0.ɵɵnamespaceSVG();
|
|
ɵngcc0.ɵɵelement(0, "circle", 3);
|
|
} if (rf & 2) {
|
|
const ctx_r1 = ɵngcc0.ɵɵnextContext();
|
|
ɵngcc0.ɵɵstyleProp("stroke-dashoffset", ctx_r1._getStrokeDashOffset(), "px")("stroke-dasharray", ctx_r1._getStrokeCircumference(), "px")("stroke-width", ctx_r1._getCircleStrokeWidth(), "%");
|
|
ɵngcc0.ɵɵattribute("r", ctx_r1._getCircleRadius());
|
|
} }
|
|
const _c0 = ".mat-progress-spinner{display:block;position:relative;overflow:hidden}.mat-progress-spinner svg{position:absolute;transform:rotate(-90deg);top:0;left:0;transform-origin:center;overflow:visible}.mat-progress-spinner circle{fill:transparent;transform-origin:center;transition:stroke-dashoffset 225ms linear}._mat-animation-noopable.mat-progress-spinner circle{transition:none;animation:none}.cdk-high-contrast-active .mat-progress-spinner circle{stroke:currentColor;stroke:CanvasText}.mat-progress-spinner.mat-progress-spinner-indeterminate-animation[mode=indeterminate] svg{animation:mat-progress-spinner-linear-rotate 2000ms linear infinite}._mat-animation-noopable.mat-progress-spinner.mat-progress-spinner-indeterminate-animation[mode=indeterminate] svg{transition:none;animation:none}.mat-progress-spinner.mat-progress-spinner-indeterminate-animation[mode=indeterminate] circle{transition-property:stroke;animation-duration:4000ms;animation-timing-function:cubic-bezier(0.35, 0, 0.25, 1);animation-iteration-count:infinite}._mat-animation-noopable.mat-progress-spinner.mat-progress-spinner-indeterminate-animation[mode=indeterminate] circle{transition:none;animation:none}.mat-progress-spinner.mat-progress-spinner-indeterminate-fallback-animation[mode=indeterminate] svg{animation:mat-progress-spinner-stroke-rotate-fallback 10000ms cubic-bezier(0.87, 0.03, 0.33, 1) infinite}._mat-animation-noopable.mat-progress-spinner.mat-progress-spinner-indeterminate-fallback-animation[mode=indeterminate] svg{transition:none;animation:none}.mat-progress-spinner.mat-progress-spinner-indeterminate-fallback-animation[mode=indeterminate] circle{transition-property:stroke}._mat-animation-noopable.mat-progress-spinner.mat-progress-spinner-indeterminate-fallback-animation[mode=indeterminate] circle{transition:none;animation:none}@keyframes mat-progress-spinner-linear-rotate{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes mat-progress-spinner-stroke-rotate-100{0%{stroke-dashoffset:268.606171575px;transform:rotate(0)}12.5%{stroke-dashoffset:56.5486677px;transform:rotate(0)}12.5001%{stroke-dashoffset:56.5486677px;transform:rotateX(180deg) rotate(72.5deg)}25%{stroke-dashoffset:268.606171575px;transform:rotateX(180deg) rotate(72.5deg)}25.0001%{stroke-dashoffset:268.606171575px;transform:rotate(270deg)}37.5%{stroke-dashoffset:56.5486677px;transform:rotate(270deg)}37.5001%{stroke-dashoffset:56.5486677px;transform:rotateX(180deg) rotate(161.5deg)}50%{stroke-dashoffset:268.606171575px;transform:rotateX(180deg) rotate(161.5deg)}50.0001%{stroke-dashoffset:268.606171575px;transform:rotate(180deg)}62.5%{stroke-dashoffset:56.5486677px;transform:rotate(180deg)}62.5001%{stroke-dashoffset:56.5486677px;transform:rotateX(180deg) rotate(251.5deg)}75%{stroke-dashoffset:268.606171575px;transform:rotateX(180deg) rotate(251.5deg)}75.0001%{stroke-dashoffset:268.606171575px;transform:rotate(90deg)}87.5%{stroke-dashoffset:56.5486677px;transform:rotate(90deg)}87.5001%{stroke-dashoffset:56.5486677px;transform:rotateX(180deg) rotate(341.5deg)}100%{stroke-dashoffset:268.606171575px;transform:rotateX(180deg) rotate(341.5deg)}}@keyframes mat-progress-spinner-stroke-rotate-fallback{0%{transform:rotate(0deg)}25%{transform:rotate(1170deg)}50%{transform:rotate(2340deg)}75%{transform:rotate(3510deg)}100%{transform:rotate(4680deg)}}\n";
|
|
const BASE_SIZE = 100;
|
|
/**
|
|
* Base reference stroke width of the spinner.
|
|
* @docs-private
|
|
*/
|
|
const BASE_STROKE_WIDTH = 10;
|
|
// Boilerplate for applying mixins to MatProgressSpinner.
|
|
/** @docs-private */
|
|
const _MatProgressSpinnerBase = mixinColor(class {
|
|
constructor(_elementRef) {
|
|
this._elementRef = _elementRef;
|
|
}
|
|
}, 'primary');
|
|
/** Injection token to be used to override the default options for `mat-progress-spinner`. */
|
|
const MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS = new InjectionToken('mat-progress-spinner-default-options', {
|
|
providedIn: 'root',
|
|
factory: MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY,
|
|
});
|
|
/** @docs-private */
|
|
function MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY() {
|
|
return { diameter: BASE_SIZE };
|
|
}
|
|
// .0001 percentage difference is necessary in order to avoid unwanted animation frames
|
|
// for example because the animation duration is 4 seconds, .1% accounts to 4ms
|
|
// which are enough to see the flicker described in
|
|
// https://github.com/angular/components/issues/8984
|
|
const INDETERMINATE_ANIMATION_TEMPLATE = `
|
|
@keyframes mat-progress-spinner-stroke-rotate-DIAMETER {
|
|
0% { stroke-dashoffset: START_VALUE; transform: rotate(0); }
|
|
12.5% { stroke-dashoffset: END_VALUE; transform: rotate(0); }
|
|
12.5001% { stroke-dashoffset: END_VALUE; transform: rotateX(180deg) rotate(72.5deg); }
|
|
25% { stroke-dashoffset: START_VALUE; transform: rotateX(180deg) rotate(72.5deg); }
|
|
|
|
25.0001% { stroke-dashoffset: START_VALUE; transform: rotate(270deg); }
|
|
37.5% { stroke-dashoffset: END_VALUE; transform: rotate(270deg); }
|
|
37.5001% { stroke-dashoffset: END_VALUE; transform: rotateX(180deg) rotate(161.5deg); }
|
|
50% { stroke-dashoffset: START_VALUE; transform: rotateX(180deg) rotate(161.5deg); }
|
|
|
|
50.0001% { stroke-dashoffset: START_VALUE; transform: rotate(180deg); }
|
|
62.5% { stroke-dashoffset: END_VALUE; transform: rotate(180deg); }
|
|
62.5001% { stroke-dashoffset: END_VALUE; transform: rotateX(180deg) rotate(251.5deg); }
|
|
75% { stroke-dashoffset: START_VALUE; transform: rotateX(180deg) rotate(251.5deg); }
|
|
|
|
75.0001% { stroke-dashoffset: START_VALUE; transform: rotate(90deg); }
|
|
87.5% { stroke-dashoffset: END_VALUE; transform: rotate(90deg); }
|
|
87.5001% { stroke-dashoffset: END_VALUE; transform: rotateX(180deg) rotate(341.5deg); }
|
|
100% { stroke-dashoffset: START_VALUE; transform: rotateX(180deg) rotate(341.5deg); }
|
|
}
|
|
`;
|
|
/**
|
|
* `<mat-progress-spinner>` component.
|
|
*/
|
|
class MatProgressSpinner extends _MatProgressSpinnerBase {
|
|
constructor(elementRef, platform, _document, animationMode, defaults) {
|
|
super(elementRef);
|
|
this._document = _document;
|
|
this._diameter = BASE_SIZE;
|
|
this._value = 0;
|
|
this._fallbackAnimation = false;
|
|
/** Mode of the progress circle */
|
|
this.mode = 'determinate';
|
|
const trackedDiameters = MatProgressSpinner._diameters;
|
|
this._spinnerAnimationLabel = this._getSpinnerAnimationLabel();
|
|
// The base size is already inserted via the component's structural styles. We still
|
|
// need to track it so we don't end up adding the same styles again.
|
|
if (!trackedDiameters.has(_document.head)) {
|
|
trackedDiameters.set(_document.head, new Set([BASE_SIZE]));
|
|
}
|
|
this._fallbackAnimation = platform.EDGE || platform.TRIDENT;
|
|
this._noopAnimations = animationMode === 'NoopAnimations' &&
|
|
(!!defaults && !defaults._forceAnimations);
|
|
if (defaults) {
|
|
if (defaults.diameter) {
|
|
this.diameter = defaults.diameter;
|
|
}
|
|
if (defaults.strokeWidth) {
|
|
this.strokeWidth = defaults.strokeWidth;
|
|
}
|
|
}
|
|
}
|
|
/** The diameter of the progress spinner (will set width and height of svg). */
|
|
get diameter() { return this._diameter; }
|
|
set diameter(size) {
|
|
this._diameter = coerceNumberProperty(size);
|
|
this._spinnerAnimationLabel = this._getSpinnerAnimationLabel();
|
|
// If this is set before `ngOnInit`, the style root may not have been resolved yet.
|
|
if (!this._fallbackAnimation && this._styleRoot) {
|
|
this._attachStyleNode();
|
|
}
|
|
}
|
|
/** Stroke width of the progress spinner. */
|
|
get strokeWidth() {
|
|
return this._strokeWidth || this.diameter / 10;
|
|
}
|
|
set strokeWidth(value) {
|
|
this._strokeWidth = coerceNumberProperty(value);
|
|
}
|
|
/** Value of the progress circle. */
|
|
get value() {
|
|
return this.mode === 'determinate' ? this._value : 0;
|
|
}
|
|
set value(newValue) {
|
|
this._value = Math.max(0, Math.min(100, coerceNumberProperty(newValue)));
|
|
}
|
|
ngOnInit() {
|
|
const element = this._elementRef.nativeElement;
|
|
// Note that we need to look up the root node in ngOnInit, rather than the constructor, because
|
|
// Angular seems to create the element outside the shadow root and then moves it inside, if the
|
|
// node is inside an `ngIf` and a ShadowDom-encapsulated component.
|
|
this._styleRoot = _getShadowRoot(element) || this._document.head;
|
|
this._attachStyleNode();
|
|
// On IE and Edge, we can't animate the `stroke-dashoffset`
|
|
// reliably so we fall back to a non-spec animation.
|
|
const animationClass = `mat-progress-spinner-indeterminate${this._fallbackAnimation ? '-fallback' : ''}-animation`;
|
|
element.classList.add(animationClass);
|
|
}
|
|
/** The radius of the spinner, adjusted for stroke width. */
|
|
_getCircleRadius() {
|
|
return (this.diameter - BASE_STROKE_WIDTH) / 2;
|
|
}
|
|
/** The view box of the spinner's svg element. */
|
|
_getViewBox() {
|
|
const viewBox = this._getCircleRadius() * 2 + this.strokeWidth;
|
|
return `0 0 ${viewBox} ${viewBox}`;
|
|
}
|
|
/** The stroke circumference of the svg circle. */
|
|
_getStrokeCircumference() {
|
|
return 2 * Math.PI * this._getCircleRadius();
|
|
}
|
|
/** The dash offset of the svg circle. */
|
|
_getStrokeDashOffset() {
|
|
if (this.mode === 'determinate') {
|
|
return this._getStrokeCircumference() * (100 - this._value) / 100;
|
|
}
|
|
// In fallback mode set the circle to 80% and rotate it with CSS.
|
|
if (this._fallbackAnimation && this.mode === 'indeterminate') {
|
|
return this._getStrokeCircumference() * 0.2;
|
|
}
|
|
return null;
|
|
}
|
|
/** Stroke width of the circle in percent. */
|
|
_getCircleStrokeWidth() {
|
|
return this.strokeWidth / this.diameter * 100;
|
|
}
|
|
/** Dynamically generates a style tag containing the correct animation for this diameter. */
|
|
_attachStyleNode() {
|
|
const styleRoot = this._styleRoot;
|
|
const currentDiameter = this._diameter;
|
|
const diameters = MatProgressSpinner._diameters;
|
|
let diametersForElement = diameters.get(styleRoot);
|
|
if (!diametersForElement || !diametersForElement.has(currentDiameter)) {
|
|
const styleTag = this._document.createElement('style');
|
|
styleTag.setAttribute('mat-spinner-animation', this._spinnerAnimationLabel);
|
|
styleTag.textContent = this._getAnimationText();
|
|
styleRoot.appendChild(styleTag);
|
|
if (!diametersForElement) {
|
|
diametersForElement = new Set();
|
|
diameters.set(styleRoot, diametersForElement);
|
|
}
|
|
diametersForElement.add(currentDiameter);
|
|
}
|
|
}
|
|
/** Generates animation styles adjusted for the spinner's diameter. */
|
|
_getAnimationText() {
|
|
const strokeCircumference = this._getStrokeCircumference();
|
|
return INDETERMINATE_ANIMATION_TEMPLATE
|
|
// Animation should begin at 5% and end at 80%
|
|
.replace(/START_VALUE/g, `${0.95 * strokeCircumference}`)
|
|
.replace(/END_VALUE/g, `${0.2 * strokeCircumference}`)
|
|
.replace(/DIAMETER/g, `${this._spinnerAnimationLabel}`);
|
|
}
|
|
/** Returns the circle diameter formatted for use with the animation-name CSS property. */
|
|
_getSpinnerAnimationLabel() {
|
|
// The string of a float point number will include a period ‘.’ character,
|
|
// which is not valid for a CSS animation-name.
|
|
return this.diameter.toString().replace('.', '_');
|
|
}
|
|
}
|
|
MatProgressSpinner.ɵfac = function MatProgressSpinner_Factory(t) { return new (t || MatProgressSpinner)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ElementRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc1.Platform), ɵngcc0.ɵɵdirectiveInject(DOCUMENT, 8), ɵngcc0.ɵɵdirectiveInject(ANIMATION_MODULE_TYPE, 8), ɵngcc0.ɵɵdirectiveInject(MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS)); };
|
|
MatProgressSpinner.ɵcmp = /*@__PURE__*/ ɵngcc0.ɵɵdefineComponent({ type: MatProgressSpinner, selectors: [["mat-progress-spinner"]], hostAttrs: ["role", "progressbar", "tabindex", "-1", 1, "mat-progress-spinner"], hostVars: 10, hostBindings: function MatProgressSpinner_HostBindings(rf, ctx) { if (rf & 2) {
|
|
ɵngcc0.ɵɵattribute("aria-valuemin", ctx.mode === "determinate" ? 0 : null)("aria-valuemax", ctx.mode === "determinate" ? 100 : null)("aria-valuenow", ctx.mode === "determinate" ? ctx.value : null)("mode", ctx.mode);
|
|
ɵngcc0.ɵɵstyleProp("width", ctx.diameter, "px")("height", ctx.diameter, "px");
|
|
ɵngcc0.ɵɵclassProp("_mat-animation-noopable", ctx._noopAnimations);
|
|
} }, inputs: { color: "color", mode: "mode", diameter: "diameter", strokeWidth: "strokeWidth", value: "value" }, exportAs: ["matProgressSpinner"], features: [ɵngcc0.ɵɵInheritDefinitionFeature], decls: 3, vars: 8, consts: [["preserveAspectRatio", "xMidYMid meet", "focusable", "false", "aria-hidden", "true", 3, "ngSwitch"], ["cx", "50%", "cy", "50%", 3, "animation-name", "stroke-dashoffset", "stroke-dasharray", "stroke-width", 4, "ngSwitchCase"], ["cx", "50%", "cy", "50%", 3, "stroke-dashoffset", "stroke-dasharray", "stroke-width", 4, "ngSwitchCase"], ["cx", "50%", "cy", "50%"]], template: function MatProgressSpinner_Template(rf, ctx) { if (rf & 1) {
|
|
ɵngcc0.ɵɵnamespaceSVG();
|
|
ɵngcc0.ɵɵelementStart(0, "svg", 0);
|
|
ɵngcc0.ɵɵtemplate(1, MatProgressSpinner__svg_circle_1_Template, 1, 9, "circle", 1);
|
|
ɵngcc0.ɵɵtemplate(2, MatProgressSpinner__svg_circle_2_Template, 1, 7, "circle", 2);
|
|
ɵngcc0.ɵɵelementEnd();
|
|
} if (rf & 2) {
|
|
ɵngcc0.ɵɵstyleProp("width", ctx.diameter, "px")("height", ctx.diameter, "px");
|
|
ɵngcc0.ɵɵproperty("ngSwitch", ctx.mode === "indeterminate");
|
|
ɵngcc0.ɵɵattribute("viewBox", ctx._getViewBox());
|
|
ɵngcc0.ɵɵadvance(1);
|
|
ɵngcc0.ɵɵproperty("ngSwitchCase", true);
|
|
ɵngcc0.ɵɵadvance(1);
|
|
ɵngcc0.ɵɵproperty("ngSwitchCase", false);
|
|
} }, directives: [ɵngcc2.NgSwitch, ɵngcc2.NgSwitchCase], styles: [_c0], encapsulation: 2, changeDetection: 0 });
|
|
/**
|
|
* Tracks diameters of existing instances to de-dupe generated styles (default d = 100).
|
|
* We need to keep track of which elements the diameters were attached to, because for
|
|
* elements in the Shadow DOM the style tags are attached to the shadow root, rather
|
|
* than the document head.
|
|
*/
|
|
MatProgressSpinner._diameters = new WeakMap();
|
|
MatProgressSpinner.ctorParameters = () => [
|
|
{ type: ElementRef },
|
|
{ type: Platform },
|
|
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] },
|
|
{ type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] },
|
|
{ type: undefined, decorators: [{ type: Inject, args: [MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS,] }] }
|
|
];
|
|
MatProgressSpinner.propDecorators = {
|
|
diameter: [{ type: Input }],
|
|
strokeWidth: [{ type: Input }],
|
|
mode: [{ type: Input }],
|
|
value: [{ type: Input }]
|
|
};
|
|
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(MatProgressSpinner, [{
|
|
type: Component,
|
|
args: [{
|
|
selector: 'mat-progress-spinner',
|
|
exportAs: 'matProgressSpinner',
|
|
host: {
|
|
'role': 'progressbar',
|
|
'class': 'mat-progress-spinner',
|
|
// set tab index to -1 so screen readers will read the aria-label
|
|
// Note: there is a known issue with JAWS that does not read progressbar aria labels on FireFox
|
|
'tabindex': '-1',
|
|
'[class._mat-animation-noopable]': `_noopAnimations`,
|
|
'[style.width.px]': 'diameter',
|
|
'[style.height.px]': 'diameter',
|
|
'[attr.aria-valuemin]': 'mode === "determinate" ? 0 : null',
|
|
'[attr.aria-valuemax]': 'mode === "determinate" ? 100 : null',
|
|
'[attr.aria-valuenow]': 'mode === "determinate" ? value : null',
|
|
'[attr.mode]': 'mode'
|
|
},
|
|
inputs: ['color'],
|
|
template: "<!--\n preserveAspectRatio of xMidYMid meet as the center of the viewport is the circle's\n center. The center of the circle will remain at the center of the mat-progress-spinner\n element containing the SVG. `focusable=\"false\"` prevents IE from allowing the user to\n tab into the SVG element.\n-->\n<!--\n All children need to be hidden for screen readers in order to support ChromeVox.\n More context in the issue: https://github.com/angular/components/issues/22165.\n-->\n<svg\n [style.width.px]=\"diameter\"\n [style.height.px]=\"diameter\"\n [attr.viewBox]=\"_getViewBox()\"\n preserveAspectRatio=\"xMidYMid meet\"\n focusable=\"false\"\n [ngSwitch]=\"mode === 'indeterminate'\"\n aria-hidden=\"true\">\n\n <!--\n Technically we can reuse the same `circle` element, however Safari has an issue that breaks\n the SVG rendering in determinate mode, after switching between indeterminate and determinate.\n Using a different element avoids the issue. An alternative to this is adding `display: none`\n for a split second and then removing it when switching between modes, but it's hard to know\n for how long to hide the element and it can cause the UI to blink.\n -->\n <circle\n *ngSwitchCase=\"true\"\n cx=\"50%\"\n cy=\"50%\"\n [attr.r]=\"_getCircleRadius()\"\n [style.animation-name]=\"'mat-progress-spinner-stroke-rotate-' + _spinnerAnimationLabel\"\n [style.stroke-dashoffset.px]=\"_getStrokeDashOffset()\"\n [style.stroke-dasharray.px]=\"_getStrokeCircumference()\"\n [style.stroke-width.%]=\"_getCircleStrokeWidth()\"></circle>\n\n <circle\n *ngSwitchCase=\"false\"\n cx=\"50%\"\n cy=\"50%\"\n [attr.r]=\"_getCircleRadius()\"\n [style.stroke-dashoffset.px]=\"_getStrokeDashOffset()\"\n [style.stroke-dasharray.px]=\"_getStrokeCircumference()\"\n [style.stroke-width.%]=\"_getCircleStrokeWidth()\"></circle>\n</svg>\n",
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
encapsulation: ViewEncapsulation.None,
|
|
styles: [".mat-progress-spinner{display:block;position:relative;overflow:hidden}.mat-progress-spinner svg{position:absolute;transform:rotate(-90deg);top:0;left:0;transform-origin:center;overflow:visible}.mat-progress-spinner circle{fill:transparent;transform-origin:center;transition:stroke-dashoffset 225ms linear}._mat-animation-noopable.mat-progress-spinner circle{transition:none;animation:none}.cdk-high-contrast-active .mat-progress-spinner circle{stroke:currentColor;stroke:CanvasText}.mat-progress-spinner.mat-progress-spinner-indeterminate-animation[mode=indeterminate] svg{animation:mat-progress-spinner-linear-rotate 2000ms linear infinite}._mat-animation-noopable.mat-progress-spinner.mat-progress-spinner-indeterminate-animation[mode=indeterminate] svg{transition:none;animation:none}.mat-progress-spinner.mat-progress-spinner-indeterminate-animation[mode=indeterminate] circle{transition-property:stroke;animation-duration:4000ms;animation-timing-function:cubic-bezier(0.35, 0, 0.25, 1);animation-iteration-count:infinite}._mat-animation-noopable.mat-progress-spinner.mat-progress-spinner-indeterminate-animation[mode=indeterminate] circle{transition:none;animation:none}.mat-progress-spinner.mat-progress-spinner-indeterminate-fallback-animation[mode=indeterminate] svg{animation:mat-progress-spinner-stroke-rotate-fallback 10000ms cubic-bezier(0.87, 0.03, 0.33, 1) infinite}._mat-animation-noopable.mat-progress-spinner.mat-progress-spinner-indeterminate-fallback-animation[mode=indeterminate] svg{transition:none;animation:none}.mat-progress-spinner.mat-progress-spinner-indeterminate-fallback-animation[mode=indeterminate] circle{transition-property:stroke}._mat-animation-noopable.mat-progress-spinner.mat-progress-spinner-indeterminate-fallback-animation[mode=indeterminate] circle{transition:none;animation:none}@keyframes mat-progress-spinner-linear-rotate{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes mat-progress-spinner-stroke-rotate-100{0%{stroke-dashoffset:268.606171575px;transform:rotate(0)}12.5%{stroke-dashoffset:56.5486677px;transform:rotate(0)}12.5001%{stroke-dashoffset:56.5486677px;transform:rotateX(180deg) rotate(72.5deg)}25%{stroke-dashoffset:268.606171575px;transform:rotateX(180deg) rotate(72.5deg)}25.0001%{stroke-dashoffset:268.606171575px;transform:rotate(270deg)}37.5%{stroke-dashoffset:56.5486677px;transform:rotate(270deg)}37.5001%{stroke-dashoffset:56.5486677px;transform:rotateX(180deg) rotate(161.5deg)}50%{stroke-dashoffset:268.606171575px;transform:rotateX(180deg) rotate(161.5deg)}50.0001%{stroke-dashoffset:268.606171575px;transform:rotate(180deg)}62.5%{stroke-dashoffset:56.5486677px;transform:rotate(180deg)}62.5001%{stroke-dashoffset:56.5486677px;transform:rotateX(180deg) rotate(251.5deg)}75%{stroke-dashoffset:268.606171575px;transform:rotateX(180deg) rotate(251.5deg)}75.0001%{stroke-dashoffset:268.606171575px;transform:rotate(90deg)}87.5%{stroke-dashoffset:56.5486677px;transform:rotate(90deg)}87.5001%{stroke-dashoffset:56.5486677px;transform:rotateX(180deg) rotate(341.5deg)}100%{stroke-dashoffset:268.606171575px;transform:rotateX(180deg) rotate(341.5deg)}}@keyframes mat-progress-spinner-stroke-rotate-fallback{0%{transform:rotate(0deg)}25%{transform:rotate(1170deg)}50%{transform:rotate(2340deg)}75%{transform:rotate(3510deg)}100%{transform:rotate(4680deg)}}\n"]
|
|
}]
|
|
}], function () { return [{ type: ɵngcc0.ElementRef }, { type: ɵngcc1.Platform }, { type: undefined, decorators: [{
|
|
type: Optional
|
|
}, {
|
|
type: Inject,
|
|
args: [DOCUMENT]
|
|
}] }, { type: String, decorators: [{
|
|
type: Optional
|
|
}, {
|
|
type: Inject,
|
|
args: [ANIMATION_MODULE_TYPE]
|
|
}] }, { type: undefined, decorators: [{
|
|
type: Inject,
|
|
args: [MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS]
|
|
}] }]; }, { mode: [{
|
|
type: Input
|
|
}], diameter: [{
|
|
type: Input
|
|
}], strokeWidth: [{
|
|
type: Input
|
|
}], value: [{
|
|
type: Input
|
|
}] }); })();
|
|
/**
|
|
* `<mat-spinner>` component.
|
|
*
|
|
* This is a component definition to be used as a convenience reference to create an
|
|
* indeterminate `<mat-progress-spinner>` instance.
|
|
*/
|
|
class MatSpinner extends MatProgressSpinner {
|
|
constructor(elementRef, platform, document, animationMode, defaults) {
|
|
super(elementRef, platform, document, animationMode, defaults);
|
|
this.mode = 'indeterminate';
|
|
}
|
|
}
|
|
MatSpinner.ɵfac = function MatSpinner_Factory(t) { return new (t || MatSpinner)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ElementRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc1.Platform), ɵngcc0.ɵɵdirectiveInject(DOCUMENT, 8), ɵngcc0.ɵɵdirectiveInject(ANIMATION_MODULE_TYPE, 8), ɵngcc0.ɵɵdirectiveInject(MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS)); };
|
|
MatSpinner.ɵcmp = /*@__PURE__*/ ɵngcc0.ɵɵdefineComponent({ type: MatSpinner, selectors: [["mat-spinner"]], hostAttrs: ["role", "progressbar", "mode", "indeterminate", 1, "mat-spinner", "mat-progress-spinner"], hostVars: 6, hostBindings: function MatSpinner_HostBindings(rf, ctx) { if (rf & 2) {
|
|
ɵngcc0.ɵɵstyleProp("width", ctx.diameter, "px")("height", ctx.diameter, "px");
|
|
ɵngcc0.ɵɵclassProp("_mat-animation-noopable", ctx._noopAnimations);
|
|
} }, inputs: { color: "color" }, features: [ɵngcc0.ɵɵInheritDefinitionFeature], decls: 3, vars: 8, consts: [["preserveAspectRatio", "xMidYMid meet", "focusable", "false", "aria-hidden", "true", 3, "ngSwitch"], ["cx", "50%", "cy", "50%", 3, "animation-name", "stroke-dashoffset", "stroke-dasharray", "stroke-width", 4, "ngSwitchCase"], ["cx", "50%", "cy", "50%", 3, "stroke-dashoffset", "stroke-dasharray", "stroke-width", 4, "ngSwitchCase"], ["cx", "50%", "cy", "50%"]], template: function MatSpinner_Template(rf, ctx) { if (rf & 1) {
|
|
ɵngcc0.ɵɵnamespaceSVG();
|
|
ɵngcc0.ɵɵelementStart(0, "svg", 0);
|
|
ɵngcc0.ɵɵtemplate(1, MatSpinner__svg_circle_1_Template, 1, 9, "circle", 1);
|
|
ɵngcc0.ɵɵtemplate(2, MatSpinner__svg_circle_2_Template, 1, 7, "circle", 2);
|
|
ɵngcc0.ɵɵelementEnd();
|
|
} if (rf & 2) {
|
|
ɵngcc0.ɵɵstyleProp("width", ctx.diameter, "px")("height", ctx.diameter, "px");
|
|
ɵngcc0.ɵɵproperty("ngSwitch", ctx.mode === "indeterminate");
|
|
ɵngcc0.ɵɵattribute("viewBox", ctx._getViewBox());
|
|
ɵngcc0.ɵɵadvance(1);
|
|
ɵngcc0.ɵɵproperty("ngSwitchCase", true);
|
|
ɵngcc0.ɵɵadvance(1);
|
|
ɵngcc0.ɵɵproperty("ngSwitchCase", false);
|
|
} }, directives: [ɵngcc2.NgSwitch, ɵngcc2.NgSwitchCase], styles: [_c0], encapsulation: 2, changeDetection: 0 });
|
|
MatSpinner.ctorParameters = () => [
|
|
{ type: ElementRef },
|
|
{ type: Platform },
|
|
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] },
|
|
{ type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] },
|
|
{ type: undefined, decorators: [{ type: Inject, args: [MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS,] }] }
|
|
];
|
|
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(MatSpinner, [{
|
|
type: Component,
|
|
args: [{
|
|
selector: 'mat-spinner',
|
|
host: {
|
|
'role': 'progressbar',
|
|
'mode': 'indeterminate',
|
|
'class': 'mat-spinner mat-progress-spinner',
|
|
'[class._mat-animation-noopable]': `_noopAnimations`,
|
|
'[style.width.px]': 'diameter',
|
|
'[style.height.px]': 'diameter'
|
|
},
|
|
inputs: ['color'],
|
|
template: "<!--\n preserveAspectRatio of xMidYMid meet as the center of the viewport is the circle's\n center. The center of the circle will remain at the center of the mat-progress-spinner\n element containing the SVG. `focusable=\"false\"` prevents IE from allowing the user to\n tab into the SVG element.\n-->\n<!--\n All children need to be hidden for screen readers in order to support ChromeVox.\n More context in the issue: https://github.com/angular/components/issues/22165.\n-->\n<svg\n [style.width.px]=\"diameter\"\n [style.height.px]=\"diameter\"\n [attr.viewBox]=\"_getViewBox()\"\n preserveAspectRatio=\"xMidYMid meet\"\n focusable=\"false\"\n [ngSwitch]=\"mode === 'indeterminate'\"\n aria-hidden=\"true\">\n\n <!--\n Technically we can reuse the same `circle` element, however Safari has an issue that breaks\n the SVG rendering in determinate mode, after switching between indeterminate and determinate.\n Using a different element avoids the issue. An alternative to this is adding `display: none`\n for a split second and then removing it when switching between modes, but it's hard to know\n for how long to hide the element and it can cause the UI to blink.\n -->\n <circle\n *ngSwitchCase=\"true\"\n cx=\"50%\"\n cy=\"50%\"\n [attr.r]=\"_getCircleRadius()\"\n [style.animation-name]=\"'mat-progress-spinner-stroke-rotate-' + _spinnerAnimationLabel\"\n [style.stroke-dashoffset.px]=\"_getStrokeDashOffset()\"\n [style.stroke-dasharray.px]=\"_getStrokeCircumference()\"\n [style.stroke-width.%]=\"_getCircleStrokeWidth()\"></circle>\n\n <circle\n *ngSwitchCase=\"false\"\n cx=\"50%\"\n cy=\"50%\"\n [attr.r]=\"_getCircleRadius()\"\n [style.stroke-dashoffset.px]=\"_getStrokeDashOffset()\"\n [style.stroke-dasharray.px]=\"_getStrokeCircumference()\"\n [style.stroke-width.%]=\"_getCircleStrokeWidth()\"></circle>\n</svg>\n",
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
encapsulation: ViewEncapsulation.None,
|
|
styles: [".mat-progress-spinner{display:block;position:relative;overflow:hidden}.mat-progress-spinner svg{position:absolute;transform:rotate(-90deg);top:0;left:0;transform-origin:center;overflow:visible}.mat-progress-spinner circle{fill:transparent;transform-origin:center;transition:stroke-dashoffset 225ms linear}._mat-animation-noopable.mat-progress-spinner circle{transition:none;animation:none}.cdk-high-contrast-active .mat-progress-spinner circle{stroke:currentColor;stroke:CanvasText}.mat-progress-spinner.mat-progress-spinner-indeterminate-animation[mode=indeterminate] svg{animation:mat-progress-spinner-linear-rotate 2000ms linear infinite}._mat-animation-noopable.mat-progress-spinner.mat-progress-spinner-indeterminate-animation[mode=indeterminate] svg{transition:none;animation:none}.mat-progress-spinner.mat-progress-spinner-indeterminate-animation[mode=indeterminate] circle{transition-property:stroke;animation-duration:4000ms;animation-timing-function:cubic-bezier(0.35, 0, 0.25, 1);animation-iteration-count:infinite}._mat-animation-noopable.mat-progress-spinner.mat-progress-spinner-indeterminate-animation[mode=indeterminate] circle{transition:none;animation:none}.mat-progress-spinner.mat-progress-spinner-indeterminate-fallback-animation[mode=indeterminate] svg{animation:mat-progress-spinner-stroke-rotate-fallback 10000ms cubic-bezier(0.87, 0.03, 0.33, 1) infinite}._mat-animation-noopable.mat-progress-spinner.mat-progress-spinner-indeterminate-fallback-animation[mode=indeterminate] svg{transition:none;animation:none}.mat-progress-spinner.mat-progress-spinner-indeterminate-fallback-animation[mode=indeterminate] circle{transition-property:stroke}._mat-animation-noopable.mat-progress-spinner.mat-progress-spinner-indeterminate-fallback-animation[mode=indeterminate] circle{transition:none;animation:none}@keyframes mat-progress-spinner-linear-rotate{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes mat-progress-spinner-stroke-rotate-100{0%{stroke-dashoffset:268.606171575px;transform:rotate(0)}12.5%{stroke-dashoffset:56.5486677px;transform:rotate(0)}12.5001%{stroke-dashoffset:56.5486677px;transform:rotateX(180deg) rotate(72.5deg)}25%{stroke-dashoffset:268.606171575px;transform:rotateX(180deg) rotate(72.5deg)}25.0001%{stroke-dashoffset:268.606171575px;transform:rotate(270deg)}37.5%{stroke-dashoffset:56.5486677px;transform:rotate(270deg)}37.5001%{stroke-dashoffset:56.5486677px;transform:rotateX(180deg) rotate(161.5deg)}50%{stroke-dashoffset:268.606171575px;transform:rotateX(180deg) rotate(161.5deg)}50.0001%{stroke-dashoffset:268.606171575px;transform:rotate(180deg)}62.5%{stroke-dashoffset:56.5486677px;transform:rotate(180deg)}62.5001%{stroke-dashoffset:56.5486677px;transform:rotateX(180deg) rotate(251.5deg)}75%{stroke-dashoffset:268.606171575px;transform:rotateX(180deg) rotate(251.5deg)}75.0001%{stroke-dashoffset:268.606171575px;transform:rotate(90deg)}87.5%{stroke-dashoffset:56.5486677px;transform:rotate(90deg)}87.5001%{stroke-dashoffset:56.5486677px;transform:rotateX(180deg) rotate(341.5deg)}100%{stroke-dashoffset:268.606171575px;transform:rotateX(180deg) rotate(341.5deg)}}@keyframes mat-progress-spinner-stroke-rotate-fallback{0%{transform:rotate(0deg)}25%{transform:rotate(1170deg)}50%{transform:rotate(2340deg)}75%{transform:rotate(3510deg)}100%{transform:rotate(4680deg)}}\n"]
|
|
}]
|
|
}], function () { return [{ type: ɵngcc0.ElementRef }, { type: ɵngcc1.Platform }, { type: undefined, decorators: [{
|
|
type: Optional
|
|
}, {
|
|
type: Inject,
|
|
args: [DOCUMENT]
|
|
}] }, { type: String, decorators: [{
|
|
type: Optional
|
|
}, {
|
|
type: Inject,
|
|
args: [ANIMATION_MODULE_TYPE]
|
|
}] }, { type: undefined, decorators: [{
|
|
type: Inject,
|
|
args: [MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS]
|
|
}] }]; }, null); })();
|
|
|
|
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
class MatProgressSpinnerModule {
|
|
}
|
|
MatProgressSpinnerModule.ɵfac = function MatProgressSpinnerModule_Factory(t) { return new (t || MatProgressSpinnerModule)(); };
|
|
MatProgressSpinnerModule.ɵmod = /*@__PURE__*/ ɵngcc0.ɵɵdefineNgModule({ type: MatProgressSpinnerModule });
|
|
MatProgressSpinnerModule.ɵinj = /*@__PURE__*/ ɵngcc0.ɵɵdefineInjector({ imports: [[MatCommonModule, CommonModule], MatCommonModule] });
|
|
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(MatProgressSpinnerModule, [{
|
|
type: NgModule,
|
|
args: [{
|
|
imports: [MatCommonModule, CommonModule],
|
|
exports: [
|
|
MatProgressSpinner,
|
|
MatSpinner,
|
|
MatCommonModule
|
|
],
|
|
declarations: [
|
|
MatProgressSpinner,
|
|
MatSpinner
|
|
]
|
|
}]
|
|
}], null, null); })();
|
|
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && ɵngcc0.ɵɵsetNgModuleScope(MatProgressSpinnerModule, { declarations: function () { return [MatProgressSpinner, MatSpinner]; }, imports: function () { return [MatCommonModule, CommonModule]; }, exports: function () { return [MatProgressSpinner, MatSpinner, MatCommonModule]; } }); })();
|
|
|
|
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
/**
|
|
* Generated bundle index. Do not edit.
|
|
*/
|
|
|
|
export { MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS, MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY, MatProgressSpinner, MatProgressSpinnerModule, MatSpinner };
|
|
|
|
//# sourceMappingURL=progress-spinner.js.map
|