@@ -51,6 +51,7 @@ import {
51
51
RippleRef ,
52
52
RippleState ,
53
53
} from '@angular/material/core' ;
54
+ import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations' ;
54
55
import { SpecificEventListener , EventType } from '@material/base/types' ;
55
56
import { MDCSliderAdapter , MDCSliderFoundation , Thumb , TickMark } from '@material/slider' ;
56
57
import { Subscription } from 'rxjs' ;
@@ -206,14 +207,15 @@ export class MatSliderVisualThumb implements AfterViewInit, OnDestroy {
206
207
207
208
/** Handles displaying the hover ripple. */
208
209
private _showHoverRipple ( ) : void {
209
- if ( ! this . _isShowingRipple ( this . _hoverRippleRef ) ) {
210
+ if ( ! this . _slider . _noopAnimations && ! this . _isShowingRipple ( this . _hoverRippleRef ) ) {
210
211
this . _hoverRippleRef = this . _showRipple ( { enterDuration : 0 , exitDuration : 0 } ) ;
211
212
this . _hoverRippleRef ?. element . classList . add ( 'mat-mdc-slider-hover-ripple' ) ;
212
213
}
213
214
}
214
215
215
216
/** Handles displaying the focus ripple. */
216
217
private _showFocusRipple ( ) : void {
218
+ // Show the focus ripple event if noop animations are enabled.
217
219
if ( ! this . _isShowingRipple ( this . _focusRippleRef ) ) {
218
220
this . _focusRippleRef = this . _showRipple ( { enterDuration : 0 , exitDuration : 0 } ) ;
219
221
this . _focusRippleRef ?. element . classList . add ( 'mat-mdc-slider-focus-ripple' ) ;
@@ -222,7 +224,7 @@ export class MatSliderVisualThumb implements AfterViewInit, OnDestroy {
222
224
223
225
/** Handles displaying the active ripple. */
224
226
private _showActiveRipple ( ) : void {
225
- if ( ! this . _isShowingRipple ( this . _activeRippleRef ) ) {
227
+ if ( ! this . _slider . _noopAnimations && ! this . _isShowingRipple ( this . _activeRippleRef ) ) {
226
228
this . _activeRippleRef = this . _showRipple ( { enterDuration : 225 , exitDuration : 400 } ) ;
227
229
this . _activeRippleRef ?. element . classList . add ( 'mat-mdc-slider-active-ripple' ) ;
228
230
}
@@ -529,6 +531,7 @@ const _MatSliderMixinBase:
529
531
'[class.mdc-slider--disabled]' : 'disabled' ,
530
532
'[class.mdc-slider--discrete]' : 'discrete' ,
531
533
'[class.mdc-slider--tick-marks]' : 'showTickMarks' ,
534
+ '[class._mat-animation-noopable]' : '_noopAnimations' ,
532
535
} ,
533
536
exportAs : 'matSlider' ,
534
537
changeDetection : ChangeDetectionStrategy . OnPush ,
@@ -626,6 +629,9 @@ export class MatSlider extends _MatSliderMixinBase
626
629
/** The display value of the end thumb. */
627
630
_endValueIndicatorText : string ;
628
631
632
+ /** Whether animations have been disabled. */
633
+ _noopAnimations : boolean ;
634
+
629
635
/**
630
636
* Whether the browser supports pointer events.
631
637
*
@@ -648,10 +654,12 @@ export class MatSlider extends _MatSliderMixinBase
648
654
@Inject ( DOCUMENT ) document : any ,
649
655
@Optional ( ) private _dir : Directionality ,
650
656
@Optional ( ) @Inject ( MAT_RIPPLE_GLOBAL_OPTIONS )
651
- readonly _globalRippleOptions ?: RippleGlobalOptions ) {
657
+ readonly _globalRippleOptions ?: RippleGlobalOptions ,
658
+ @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) animationMode ?: string ) {
652
659
super ( _elementRef ) ;
653
660
this . _document = document ;
654
661
this . _window = this . _document . defaultView || window ;
662
+ this . _noopAnimations = animationMode === 'NoopAnimations' ;
655
663
this . _dirChangeSubscription = this . _dir . change . subscribe ( ( ) => this . _onDirChange ( ) ) ;
656
664
this . _attachUISyncEventListener ( ) ;
657
665
}
0 commit comments