Skip to content

Commit 6e8ab85

Browse files
committed
fix(material-experimental/mdc-slider): code review changes
* delete empty providers * rename thumb to _thumb and make it private in MatSliderThumb * delete thumb property in MatSliderDragEvent
1 parent d04141b commit 6e8ab85

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<mat-slider min="-5" max="0" discrete showTickMarks>
2+
<input matSliderStartThumb>
3+
<input matSliderEndThumb>
4+
</mat-slider>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@import '@material/slider/slider';
2+
@include core-styles;
3+
4+
mat-slider {
5+
display: block;
6+
}

src/material-experimental/mdc-slider/slider.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ export interface MatSliderDragEvent {
4747

4848
/** The current value of the slider. */
4949
value: number;
50-
51-
/** The thumb that was interacted with. */
52-
thumb: Thumb;
5350
}
5451

5552
/**
@@ -88,7 +85,7 @@ export class MatSliderThumb implements AfterViewInit {
8885
// If the foundation has already been initialized, we need to
8986
// relay any value updates to it so that it can update the UI.
9087
if (this._slider._initialized) {
91-
this._slider._setValue(value, this.thumb);
88+
this._slider._setValue(value, this._thumb);
9289
} else {
9390
// Setup for the MDC foundation.
9491
this._elementRef.nativeElement.setAttribute('value', `${value}`);
@@ -110,7 +107,7 @@ export class MatSliderThumb implements AfterViewInit {
110107
@Output() readonly _focus: EventEmitter<void> = new EventEmitter<void>();
111108

112109
/** Indicates which slider thumb this input corresponds to. */
113-
thumb: Thumb;
110+
private _thumb: Thumb;
114111

115112
private _document: Document;
116113

@@ -120,7 +117,7 @@ export class MatSliderThumb implements AfterViewInit {
120117
readonly _elementRef: ElementRef<HTMLInputElement>,
121118
) {
122119
this._document = document;
123-
this.thumb = _elementRef.nativeElement.hasAttribute('matSliderStartThumb')
120+
this._thumb = _elementRef.nativeElement.hasAttribute('matSliderStartThumb')
124121
? Thumb.START
125122
: Thumb.END;
126123

@@ -179,7 +176,6 @@ export class MatSliderThumb implements AfterViewInit {
179176
exportAs: 'matSlider',
180177
changeDetection: ChangeDetectionStrategy.OnPush,
181178
encapsulation: ViewEncapsulation.None,
182-
providers: [],
183179
})
184180
export class MatSlider implements AfterViewInit, OnDestroy {
185181
/** The slider thumb(s). */
@@ -471,11 +467,11 @@ class SliderAdapter implements MDCSliderAdapter {
471467
emitInputEvent = (value: number, thumb: Thumb): void => {};
472468
emitDragStartEvent = (value: number, thumb: Thumb): void => {
473469
const input = this._delegate._getInput(thumb);
474-
input.dragStart.emit({ source: input, parent: this._delegate, value, thumb });
470+
input.dragStart.emit({ source: input, parent: this._delegate, value });
475471
}
476472
emitDragEndEvent = (value: number, thumb: Thumb): void => {
477473
const input = this._delegate._getInput(thumb);
478-
input.dragEnd.emit({ source: input, parent: this._delegate, value, thumb });
474+
input.dragEnd.emit({ source: input, parent: this._delegate, value });
479475
}
480476
registerEventHandler =
481477
<K extends EventType>(evtType: K, handler: SpecificEventListener<K>): void => {

0 commit comments

Comments
 (0)