Skip to content

fix(slider): disable animations when using NoopAnimationsModule #11422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/lib/slider/slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -457,3 +457,18 @@ $mat-slider-focus-ring-size: 30px !default;
}
}
}

// Slider inside a component with disabled animations.
.mat-slider._mat-animation-noopable {
.mat-slider-track-fill,
.mat-slider-track-background,
.mat-slider-ticks,
.mat-slider-thumb-container,
.mat-slider-focus-ring,
.mat-slider-thumb,
.mat-slider-thumb-label,
.mat-slider-thumb-label-text,
.mat-slider-has-ticks .mat-slider-wrapper::after {
transition: none;
}
}
7 changes: 6 additions & 1 deletion src/lib/slider/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
Output,
ViewChild,
ViewEncapsulation,
Inject,
} from '@angular/core';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
import {
Expand All @@ -46,6 +47,7 @@ import {
mixinTabIndex,
} from '@angular/material/core';
import {Subscription} from 'rxjs';
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';

/**
* Visually, a 30px separation between tick marks looks best. This is very subjective but it is
Expand Down Expand Up @@ -126,6 +128,7 @@ export const _MatSliderMixinBase =
'[class.mat-slider-vertical]': 'vertical',
'[class.mat-slider-min-value]': '_isMinValue',
'[class.mat-slider-hide-last-tick]': 'disabled || _isMinValue && _thumbGap && _invertAxis',
'[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
},
templateUrl: 'slider.html',
styleUrls: ['slider.css'],
Expand Down Expand Up @@ -431,7 +434,9 @@ export class MatSlider extends _MatSliderMixinBase
private _focusMonitor: FocusMonitor,
private _changeDetectorRef: ChangeDetectorRef,
@Optional() private _dir: Directionality,
@Attribute('tabindex') tabIndex: string) {
@Attribute('tabindex') tabIndex: string,
// @deletion-target 7.0.0 `_animationMode` parameter to be made required.
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string) {
super(elementRef);

this.tabIndex = parseInt(tabIndex) || 0;
Expand Down