Skip to content
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
29 changes: 25 additions & 4 deletions src/material/slider/slider-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
this._slider._onValueChange(this);
this._cdr.detectChanges();
}
/** Event emitted when the `value` is changed. */
@Output() readonly valueChange: EventEmitter<number> = new EventEmitter<number>();

/** Event emitted when the slider thumb starts being dragged. */
Expand All @@ -113,7 +114,10 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
@Output() readonly dragEnd: EventEmitter<MatSliderDragEvent> =
new EventEmitter<MatSliderDragEvent>();

/** The current translateX in px of the slider visual thumb. */
/**
* The current translateX in px of the slider visual thumb.
* @docs-private
*/
get translateX(): number {
if (this._slider.min >= this._slider.max) {
this._translateX = 0;
Expand All @@ -129,9 +133,13 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
}
private _translateX: number | undefined;

/** Indicates whether this thumb is the start or end thumb. */
/**
* Indicates whether this thumb is the start or end thumb.
* @docs-private
*/
thumbPosition: _MatThumb = _MatThumb.END;

/** @docs-private */
get min(): number {
return coerceNumberProperty(this._hostElement.min);
}
Expand All @@ -140,6 +148,7 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
this._cdr.detectChanges();
}

/** @docs-private */
get max(): number {
return coerceNumberProperty(this._hostElement.max);
}
Expand All @@ -156,6 +165,7 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
this._cdr.detectChanges();
}

/** @docs-private */
get disabled(): boolean {
return coerceBooleanProperty(this._hostElement.disabled);
}
Expand All @@ -168,13 +178,15 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
}
}

/** The percentage of the slider that coincides with the value. */
get percentage(): number {
if (this._slider.min >= this._slider.max) {
return this._slider._isRtl ? 1 : 0;
}
return (this.value - this._slider.min) / (this._slider.max - this._slider.min);
}

/** @docs-private */
get fillPercentage(): number {
if (!this._slider._cachedWidth) {
return this._slider._isRtl ? 1 : 0;
Expand Down Expand Up @@ -260,6 +272,7 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
this.dragEnd.complete();
}

/** @docs-private */
initProps(): void {
this._updateWidthInactive();
this.disabled = this._slider.disabled;
Expand All @@ -269,6 +282,7 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
this._initValue();
}

/** @docs-private */
initUI(): void {
this._updateThumbUIByValue();
}
Expand Down Expand Up @@ -530,6 +544,7 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
],
})
export class MatSliderRangeThumb extends MatSliderThumb implements _MatSliderRangeThumb {
/** @docs-private */
getSibling(): _MatSliderRangeThumb | undefined {
if (!this._sibling) {
this._sibling = this._slider._getInput(this._isEndThumb ? _MatThumb.START : _MatThumb.END) as
Expand All @@ -540,7 +555,10 @@ export class MatSliderRangeThumb extends MatSliderThumb implements _MatSliderRan
}
private _sibling: MatSliderRangeThumb | undefined;

/** Returns the minimum translateX position allowed for this slider input's visual thumb. */
/**
* Returns the minimum translateX position allowed for this slider input's visual thumb.
* @docs-private
*/
getMinPos(): number {
const sibling = this.getSibling();
if (!this._isLeftThumb && sibling) {
Expand All @@ -549,7 +567,10 @@ export class MatSliderRangeThumb extends MatSliderThumb implements _MatSliderRan
return 0;
}

/** Returns the maximum translateX position allowed for this slider input's visual thumb. */
/**
* Returns the maximum translateX position allowed for this slider input's visual thumb.
* @docs-private
*/
getMaxPos(): number {
const sibling = this.getSibling();
if (this._isLeftThumb && sibling) {
Expand Down
3 changes: 3 additions & 0 deletions src/material/slider/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,10 @@ export class MatSlider

// The value indicator tooltip text for the visual slider thumb(s).

/** @docs-private */
protected startValueIndicatorText: string = '';

/** @docs-private */
protected endValueIndicatorText: string = '';

// Used to control the translateX of the visual slider thumb(s).
Expand Down
11 changes: 0 additions & 11 deletions tools/public_api_guard/material/slider.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export class MatSlider extends _MatSliderMixinBase implements AfterViewInit, Can
displayWith: (value: number) => string;
// (undocumented)
_endThumbTransform: string;
// (undocumented)
protected endValueIndicatorText: string;
_getInput(thumbPosition: _MatThumb): _MatSliderThumb | _MatSliderRangeThumb | undefined;
_getThumb(thumbPosition: _MatThumb): _MatSliderVisualThumb;
Expand Down Expand Up @@ -101,7 +100,6 @@ export class MatSlider extends _MatSliderMixinBase implements AfterViewInit, Can
set showTickMarks(v: BooleanInput);
// (undocumented)
_startThumbTransform: string;
// (undocumented)
protected startValueIndicatorText: string;
get step(): number;
set step(v: NumberInput);
Expand Down Expand Up @@ -150,7 +148,6 @@ export class MatSliderRangeThumb extends MatSliderThumb implements _MatSliderRan
_getDefaultValue(): number;
getMaxPos(): number;
getMinPos(): number;
// (undocumented)
getSibling(): _MatSliderRangeThumb | undefined;
_isEndThumb: boolean;
_isLeftThumb: boolean;
Expand Down Expand Up @@ -195,14 +192,12 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
// (undocumented)
_clamp(v: number): number;
protected readonly _destroyed: Subject<void>;
// (undocumented)
get disabled(): boolean;
set disabled(v: BooleanInput);
readonly dragEnd: EventEmitter<MatSliderDragEvent>;
readonly dragStart: EventEmitter<MatSliderDragEvent>;
// (undocumented)
readonly _elementRef: ElementRef<HTMLInputElement>;
// (undocumented)
get fillPercentage(): number;
_fixValue(event: PointerEvent): void;
// (undocumented)
Expand All @@ -211,19 +206,15 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
_getDefaultValue(): number;
_hostElement: HTMLInputElement;
_initialValue: string | undefined;
// (undocumented)
initProps(): void;
// (undocumented)
initUI(): void;
// (undocumented)
_initValue(): void;
_isActive: boolean;
_isFocused: boolean;
_knobRadius: number;
// (undocumented)
get max(): number;
set max(v: NumberInput);
// (undocumented)
get min(): number;
set min(v: NumberInput);
// (undocumented)
Expand All @@ -246,7 +237,6 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
_onPointerMove(event: PointerEvent): void;
// (undocumented)
_onPointerUp(event: PointerEvent): void;
// (undocumented)
get percentage(): number;
registerOnChange(fn: any): void;
registerOnTouched(fn: any): void;
Expand Down Expand Up @@ -277,7 +267,6 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
// (undocumented)
get value(): number;
set value(v: NumberInput);
// (undocumented)
readonly valueChange: EventEmitter<number>;
_valuetext: string;
writeValue(value: any): void;
Expand Down