@@ -51,6 +51,7 @@ import {
5151 RippleRef ,
5252 RippleState ,
5353} from '@angular/material/core' ;
54+ import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations' ;
5455import { SpecificEventListener , EventType } from '@material/base/types' ;
5556import { MDCSliderAdapter , MDCSliderFoundation , Thumb , TickMark } from '@material/slider' ;
5657import { Subscription } from 'rxjs' ;
@@ -206,14 +207,15 @@ export class MatSliderVisualThumb implements AfterViewInit, OnDestroy {
206207
207208 /** Handles displaying the hover ripple. */
208209 private _showHoverRipple ( ) : void {
209- if ( ! this . _isShowingRipple ( this . _hoverRippleRef ) ) {
210+ if ( ! this . _slider . _noopAnimations && ! this . _isShowingRipple ( this . _hoverRippleRef ) ) {
210211 this . _hoverRippleRef = this . _showRipple ( { enterDuration : 0 , exitDuration : 0 } ) ;
211212 this . _hoverRippleRef ?. element . classList . add ( 'mat-mdc-slider-hover-ripple' ) ;
212213 }
213214 }
214215
215216 /** Handles displaying the focus ripple. */
216217 private _showFocusRipple ( ) : void {
218+ // Show the focus ripple event if noop animations are enabled.
217219 if ( ! this . _isShowingRipple ( this . _focusRippleRef ) ) {
218220 this . _focusRippleRef = this . _showRipple ( { enterDuration : 0 , exitDuration : 0 } ) ;
219221 this . _focusRippleRef ?. element . classList . add ( 'mat-mdc-slider-focus-ripple' ) ;
@@ -222,7 +224,7 @@ export class MatSliderVisualThumb implements AfterViewInit, OnDestroy {
222224
223225 /** Handles displaying the active ripple. */
224226 private _showActiveRipple ( ) : void {
225- if ( ! this . _isShowingRipple ( this . _activeRippleRef ) ) {
227+ if ( ! this . _slider . _noopAnimations && ! this . _isShowingRipple ( this . _activeRippleRef ) ) {
226228 this . _activeRippleRef = this . _showRipple ( { enterDuration : 225 , exitDuration : 400 } ) ;
227229 this . _activeRippleRef ?. element . classList . add ( 'mat-mdc-slider-active-ripple' ) ;
228230 }
@@ -529,6 +531,7 @@ const _MatSliderMixinBase:
529531 '[class.mdc-slider--disabled]' : 'disabled' ,
530532 '[class.mdc-slider--discrete]' : 'discrete' ,
531533 '[class.mdc-slider--tick-marks]' : 'showTickMarks' ,
534+ '[class._mat-animation-noopable]' : '_noopAnimations' ,
532535 } ,
533536 exportAs : 'matSlider' ,
534537 changeDetection : ChangeDetectionStrategy . OnPush ,
@@ -626,6 +629,9 @@ export class MatSlider extends _MatSliderMixinBase
626629 /** The display value of the end thumb. */
627630 _endValueIndicatorText : string ;
628631
632+ /** Whether animations have been disabled. */
633+ _noopAnimations : boolean ;
634+
629635 /**
630636 * Whether the browser supports pointer events.
631637 *
@@ -648,10 +654,12 @@ export class MatSlider extends _MatSliderMixinBase
648654 @Inject ( DOCUMENT ) document : any ,
649655 @Optional ( ) private _dir : Directionality ,
650656 @Optional ( ) @Inject ( MAT_RIPPLE_GLOBAL_OPTIONS )
651- readonly _globalRippleOptions ?: RippleGlobalOptions ) {
657+ readonly _globalRippleOptions ?: RippleGlobalOptions ,
658+ @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) animationMode ?: string ) {
652659 super ( _elementRef ) ;
653660 this . _document = document ;
654661 this . _window = this . _document . defaultView || window ;
662+ this . _noopAnimations = animationMode === 'NoopAnimations' ;
655663 this . _dirChangeSubscription = this . _dir . change . subscribe ( ( ) => this . _onDirChange ( ) ) ;
656664 this . _attachUISyncEventListener ( ) ;
657665 }
0 commit comments