/
githubmirror
/
components
Обзор
Документация
Войти
/
githubmirror
/
components
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/material/core/animation/animation.ts
45 строк
1 KB
Kristiyan Kostadinov
fix(material/core): remove deprecated APIs for v21 (#31924)
29 сен 2025, 20:08
Не верифицирован
29 сен 2025, 20:08
1b06a8e
Код
Авторство
О чём код?
/** * @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.dev/license */ import {MediaMatcher} from '@angular/cdk/layout'; import {ANIMATION_MODULE_TYPE, inject, InjectionToken} from '@angular/core'; /** Object used to configure the animation in Angular Material. */ export interface AnimationsConfig { /** Whether all animations should be disabled. */ animationsDisabled?: boolean; } /** Injection token used to configure the animations in Angular Material. */ export const MATERIAL_ANIMATIONS = new InjectionToken<AnimationsConfig>('MATERIAL_ANIMATIONS'); let reducedMotion: boolean | null = null; /** * Gets the the configured animations state. * @docs-private */ export function _getAnimationsState(): 'enabled' | 'di-disabled' | 'reduced-motion' { if ( inject(MATERIAL_ANIMATIONS, {optional: true})?.animationsDisabled || inject(ANIMATION_MODULE_TYPE, {optional: true}) === 'NoopAnimations' ) { return 'di-disabled'; } reducedMotion ??= inject(MediaMatcher).matchMedia('(prefers-reduced-motion)').matches; return reducedMotion ? 'reduced-motion' : 'enabled'; } /** * Returns whether animations have been disabled by DI. Must be called in a DI context. * @docs-private */ export function _animationsDisabled(): boolean { return _getAnimationsState() !== 'enabled'; }