@angular/material
Version:
Angular Material
939 lines (934 loc) • 42.5 kB
JavaScript
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { A11yModule, FocusMonitor } from '@angular/cdk/a11y';
import { BidiModule, Directionality } from '@angular/cdk/bidi';
import { CommonModule } from '@angular/common';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, NgModule, Optional, Output, Renderer2, ViewChild, ViewEncapsulation, forwardRef } from '@angular/core';
import { GestureConfig, MatCommonModule, mixinColor, mixinDisabled } from '@angular/material/core';
import { HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';
import { __extends } from 'tslib';
import * as tslib_1 from 'tslib';
import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
import { DOWN_ARROW, END, HOME, LEFT_ARROW, PAGE_DOWN, PAGE_UP, RIGHT_ARROW, UP_ARROW } from '@angular/cdk/keycodes';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { Subscription } from 'rxjs/Subscription';
/**
* Visually, a 30px separation between tick marks looks best. This is very subjective but it is
* the default separation we chose.
*/
var MIN_AUTO_TICK_SEPARATION = 30;
/**
* The thumb gap size for a disabled slider.
*/
var DISABLED_THUMB_GAP = 7;
/**
* The thumb gap size for a non-active slider at its minimum value.
*/
var MIN_VALUE_NONACTIVE_THUMB_GAP = 7;
/**
* The thumb gap size for an active slider at its minimum value.
*/
var MIN_VALUE_ACTIVE_THUMB_GAP = 10;
/**
* Provider Expression that allows mat-slider to register as a ControlValueAccessor.
* This allows it to support [(ngModel)] and [formControl].
*/
var MAT_SLIDER_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(function () { return MatSlider; }),
multi: true
};
/**
* A simple change event emitted by the MatSlider component.
*/
var MatSliderChange = (function () {
function MatSliderChange() {
}
return MatSliderChange;
}());
/**
* \@docs-private
*/
var MatSliderBase = (function () {
/**
* @param {?} _renderer
* @param {?} _elementRef
*/
function MatSliderBase(_renderer, _elementRef) {
this._renderer = _renderer;
this._elementRef = _elementRef;
}
return MatSliderBase;
}());
var _MatSliderMixinBase = mixinColor(mixinDisabled(MatSliderBase), 'accent');
/**
* Allows users to select from a range of values by moving the slider thumb. It is similar in
* behavior to the native `<input type="range">` element.
*/
var MatSlider = (function (_super) {
__extends(MatSlider, _super);
/**
* @param {?} renderer
* @param {?} elementRef
* @param {?} _focusMonitor
* @param {?} _changeDetectorRef
* @param {?} _dir
*/
function MatSlider(renderer, elementRef, _focusMonitor, _changeDetectorRef, _dir) {
var _this = _super.call(this, renderer, elementRef) || this;
_this._focusMonitor = _focusMonitor;
_this._changeDetectorRef = _changeDetectorRef;
_this._dir = _dir;
_this._invert = false;
_this._max = 100;
_this._min = 0;
_this._step = 1;
_this._thumbLabel = false;
_this._tickInterval = 0;
_this._value = null;
_this._vertical = false;
/**
* Event emitted when the slider value has changed.
*/
_this.change = new EventEmitter();
/**
* Event emitted when the slider thumb moves.
*/
_this.input = new EventEmitter();
/**
* onTouch function registered via registerOnTouch (ControlValueAccessor).
*/
_this.onTouched = function () { };
_this._percent = 0;
/**
* Whether or not the thumb is sliding.
* Used to determine if there should be a transition for the thumb and fill track.
*/
_this._isSliding = false;
/**
* Whether or not the slider is active (clicked or sliding).
* Used to shrink and grow the thumb as according to the Material Design spec.
*/
_this._isActive = false;
/**
* The size of a tick interval as a percentage of the size of the track.
*/
_this._tickIntervalPercent = 0;
/**
* The dimensions of the slider.
*/
_this._sliderDimensions = null;
_this._controlValueAccessorChangeFn = function () { };
/**
* Subscription to the Directionality change EventEmitter.
*/
_this._dirChangeSubscription = Subscription.EMPTY;
return _this;
}
Object.defineProperty(MatSlider.prototype, "invert", {
/**
* Whether the slider is inverted.
* @return {?}
*/
get: function () { return this._invert; },
/**
* @param {?} value
* @return {?}
*/
set: function (value) {
this._invert = coerceBooleanProperty(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "max", {
/**
* The maximum value that the slider can have.
* @return {?}
*/
get: function () { return this._max; },
/**
* @param {?} v
* @return {?}
*/
set: function (v) {
this._max = coerceNumberProperty(v, this._max);
this._percent = this._calculatePercentage(this._value);
// Since this also modifies the percentage, we need to let the change detection know.
this._changeDetectorRef.markForCheck();
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "min", {
/**
* The minimum value that the slider can have.
* @return {?}
*/
get: function () { return this._min; },
/**
* @param {?} v
* @return {?}
*/
set: function (v) {
this._min = coerceNumberProperty(v, this._min);
// If the value wasn't explicitly set by the user, set it to the min.
if (this._value === null) {
this.value = this._min;
}
this._percent = this._calculatePercentage(this._value);
// Since this also modifies the percentage, we need to let the change detection know.
this._changeDetectorRef.markForCheck();
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "step", {
/**
* The values at which the thumb will snap.
* @return {?}
*/
get: function () { return this._step; },
/**
* @param {?} v
* @return {?}
*/
set: function (v) {
this._step = coerceNumberProperty(v, this._step);
if (this._step % 1 !== 0) {
this._roundLabelTo = ((this._step.toString().split('.').pop())).length;
}
// Since this could modify the label, we need to notify the change detection.
this._changeDetectorRef.markForCheck();
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "thumbLabel", {
/**
* Whether or not to show the thumb label.
* @return {?}
*/
get: function () { return this._thumbLabel; },
/**
* @param {?} value
* @return {?}
*/
set: function (value) { this._thumbLabel = coerceBooleanProperty(value); },
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "_thumbLabelDeprecated", {
/**
* @deprecated
* @return {?}
*/
get: function () { return this._thumbLabel; },
/**
* @param {?} value
* @return {?}
*/
set: function (value) { this._thumbLabel = value; },
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "tickInterval", {
/**
* How often to show ticks. Relative to the step so that a tick always appears on a step.
* Ex: Tick interval of 4 with a step of 3 will draw a tick every 4 steps (every 12 values).
* @return {?}
*/
get: function () { return this._tickInterval; },
/**
* @param {?} value
* @return {?}
*/
set: function (value) {
if (value === 'auto') {
this._tickInterval = 'auto';
}
else if (typeof value === 'number' || typeof value === 'string') {
this._tickInterval = coerceNumberProperty(value, /** @type {?} */ (this._tickInterval));
}
else {
this._tickInterval = 0;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "_tickIntervalDeprecated", {
/**
* @deprecated
* @return {?}
*/
get: function () { return this.tickInterval; },
/**
* @param {?} v
* @return {?}
*/
set: function (v) { this.tickInterval = v; },
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "value", {
/**
* Value of the slider.
* @return {?}
*/
get: function () {
// If the value needs to be read and it is still uninitialized, initialize it to the min.
if (this._value === null) {
this.value = this._min;
}
return this._value;
},
/**
* @param {?} v
* @return {?}
*/
set: function (v) {
if (v !== this._value) {
this._value = coerceNumberProperty(v, this._value || 0);
this._percent = this._calculatePercentage(this._value);
// Since this also modifies the percentage, we need to let the change detection know.
this._changeDetectorRef.markForCheck();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "vertical", {
/**
* Whether the slider is vertical.
* @return {?}
*/
get: function () { return this._vertical; },
/**
* @param {?} value
* @return {?}
*/
set: function (value) {
this._vertical = coerceBooleanProperty(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "displayValue", {
/**
* The value to be used for display purposes.
* @return {?}
*/
get: function () {
// Note that this could be improved further by rounding something like 0.999 to 1 or
// 0.899 to 0.9, however it is very performance sensitive, because it gets called on
// every change detection cycle.
if (this._roundLabelTo && this.value && this.value % 1 !== 0) {
return this.value.toFixed(this._roundLabelTo);
}
return this.value || 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "percent", {
/**
* The percentage of the slider that coincides with the value.
* @return {?}
*/
get: function () { return this._clamp(this._percent); },
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "_invertAxis", {
/**
* Whether the axis of the slider is inverted.
* (i.e. whether moving the thumb in the positive x or y direction decreases the slider's value).
* @return {?}
*/
get: function () {
// Standard non-inverted mode for a vertical slider should be dragging the thumb from bottom to
// top. However from a y-axis standpoint this is inverted.
return this.vertical ? !this.invert : this.invert;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "_isMinValue", {
/**
* Whether the slider is at its minimum value.
* @return {?}
*/
get: function () {
return this.percent === 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "_thumbGap", {
/**
* The amount of space to leave between the slider thumb and the track fill & track background
* elements.
* @return {?}
*/
get: function () {
if (this.disabled) {
return DISABLED_THUMB_GAP;
}
if (this._isMinValue && !this.thumbLabel) {
return this._isActive ? MIN_VALUE_ACTIVE_THUMB_GAP : MIN_VALUE_NONACTIVE_THUMB_GAP;
}
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "_trackBackgroundStyles", {
/**
* CSS styles for the track background element.
* @return {?}
*/
get: function () {
var /** @type {?} */ axis = this.vertical ? 'Y' : 'X';
var /** @type {?} */ sign = this._invertMouseCoords ? '-' : '';
return {
'transform': "translate" + axis + "(" + sign + this._thumbGap + "px) scale" + axis + "(" + (1 - this.percent) + ")"
};
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "_trackFillStyles", {
/**
* CSS styles for the track fill element.
* @return {?}
*/
get: function () {
var /** @type {?} */ axis = this.vertical ? 'Y' : 'X';
var /** @type {?} */ sign = this._invertMouseCoords ? '' : '-';
return {
'transform': "translate" + axis + "(" + sign + this._thumbGap + "px) scale" + axis + "(" + this.percent + ")"
};
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "_ticksContainerStyles", {
/**
* CSS styles for the ticks container element.
* @return {?}
*/
get: function () {
var /** @type {?} */ axis = this.vertical ? 'Y' : 'X';
// For a horizontal slider in RTL languages we push the ticks container off the left edge
// instead of the right edge to avoid causing a horizontal scrollbar to appear.
var /** @type {?} */ sign = !this.vertical && this._direction == 'rtl' ? '' : '-';
var /** @type {?} */ offset = this._tickIntervalPercent / 2 * 100;
return {
'transform': "translate" + axis + "(" + sign + offset + "%)"
};
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "_ticksStyles", {
/**
* CSS styles for the ticks element.
* @return {?}
*/
get: function () {
var /** @type {?} */ tickSize = this._tickIntervalPercent * 100;
var /** @type {?} */ backgroundSize = this.vertical ? "2px " + tickSize + "%" : tickSize + "% 2px";
var /** @type {?} */ axis = this.vertical ? 'Y' : 'X';
// Depending on the direction we pushed the ticks container, push the ticks the opposite
// direction to re-center them but clip off the end edge. In RTL languages we need to flip the
// ticks 180 degrees so we're really cutting off the end edge abd not the start.
var /** @type {?} */ sign = !this.vertical && this._direction == 'rtl' ? '-' : '';
var /** @type {?} */ rotate = !this.vertical && this._direction == 'rtl' ? ' rotate(180deg)' : '';
var /** @type {?} */ styles = {
'backgroundSize': backgroundSize,
// Without translateZ ticks sometimes jitter as the slider moves on Chrome & Firefox.
'transform': "translateZ(0) translate" + axis + "(" + sign + tickSize / 2 + "%)" + rotate
};
if (this._isMinValue && this._thumbGap) {
var /** @type {?} */ side = this.vertical ?
(this._invertAxis ? 'Bottom' : 'Top') :
(this._invertAxis ? 'Right' : 'Left');
styles["padding" + side] = this._thumbGap + "px";
}
return styles;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "_thumbContainerStyles", {
/**
* @return {?}
*/
get: function () {
var /** @type {?} */ axis = this.vertical ? 'Y' : 'X';
// For a horizontal slider in RTL languages we push the thumb container off the left edge
// instead of the right edge to avoid causing a horizontal scrollbar to appear.
var /** @type {?} */ invertOffset = (this._direction == 'rtl' && !this.vertical) ? !this._invertAxis : this._invertAxis;
var /** @type {?} */ offset = (invertOffset ? this.percent : 1 - this.percent) * 100;
return {
'transform': "translate" + axis + "(-" + offset + "%)"
};
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "_invertMouseCoords", {
/**
* Whether mouse events should be converted to a slider position by calculating their distance
* from the right or bottom edge of the slider as opposed to the top or left.
* @return {?}
*/
get: function () {
return (this._direction == 'rtl' && !this.vertical) ? !this._invertAxis : this._invertAxis;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatSlider.prototype, "_direction", {
/**
* The language direction for this slider element.
* @return {?}
*/
get: function () {
return (this._dir && this._dir.value == 'rtl') ? 'rtl' : 'ltr';
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
MatSlider.prototype.ngOnInit = function () {
var _this = this;
this._focusMonitor
.monitor(this._elementRef.nativeElement, this._renderer, true)
.subscribe(function (origin) {
_this._isActive = !!origin && origin !== 'keyboard';
_this._changeDetectorRef.detectChanges();
});
if (this._dir) {
this._dirChangeSubscription = this._dir.change.subscribe(function () {
_this._changeDetectorRef.markForCheck();
});
}
};
/**
* @return {?}
*/
MatSlider.prototype.ngOnDestroy = function () {
this._focusMonitor.stopMonitoring(this._elementRef.nativeElement);
this._dirChangeSubscription.unsubscribe();
};
/**
* @return {?}
*/
MatSlider.prototype._onMouseenter = function () {
if (this.disabled) {
return;
}
// We save the dimensions of the slider here so we can use them to update the spacing of the
// ticks and determine where on the slider click and slide events happen.
this._sliderDimensions = this._getSliderDimensions();
this._updateTickIntervalPercent();
};
/**
* @param {?} event
* @return {?}
*/
MatSlider.prototype._onClick = function (event) {
if (this.disabled) {
return;
}
var /** @type {?} */ oldValue = this.value;
this._isSliding = false;
this._focusHostElement();
this._updateValueFromPosition({ x: event.clientX, y: event.clientY });
/* Emit a change and input event if the value changed. */
if (oldValue != this.value) {
this._emitInputEvent();
this._emitChangeEvent();
}
};
/**
* @param {?} event
* @return {?}
*/
MatSlider.prototype._onSlide = function (event) {
if (this.disabled) {
return;
}
// The slide start event sometimes fails to fire on iOS, so if we're not already in the sliding
// state, call the slide start handler manually.
if (!this._isSliding) {
this._onSlideStart(null);
}
// Prevent the slide from selecting anything else.
event.preventDefault();
var /** @type {?} */ oldValue = this.value;
this._updateValueFromPosition({ x: event.center.x, y: event.center.y });
// Native range elements always emit `input` events when the value changed while sliding.
if (oldValue != this.value) {
this._emitInputEvent();
}
};
/**
* @param {?} event
* @return {?}
*/
MatSlider.prototype._onSlideStart = function (event) {
if (this.disabled || this._isSliding) {
return;
}
// Simulate mouseenter in case this is a mobile device.
this._onMouseenter();
this._isSliding = true;
this._focusHostElement();
this._valueOnSlideStart = this.value;
if (event) {
this._updateValueFromPosition({ x: event.center.x, y: event.center.y });
event.preventDefault();
}
};
/**
* @return {?}
*/
MatSlider.prototype._onSlideEnd = function () {
this._isSliding = false;
if (this._valueOnSlideStart != this.value) {
this._emitChangeEvent();
}
this._valueOnSlideStart = null;
};
/**
* @return {?}
*/
MatSlider.prototype._onFocus = function () {
// We save the dimensions of the slider here so we can use them to update the spacing of the
// ticks and determine where on the slider click and slide events happen.
this._sliderDimensions = this._getSliderDimensions();
this._updateTickIntervalPercent();
};
/**
* @return {?}
*/
MatSlider.prototype._onBlur = function () {
this.onTouched();
};
/**
* @param {?} event
* @return {?}
*/
MatSlider.prototype._onKeydown = function (event) {
if (this.disabled) {
return;
}
var /** @type {?} */ oldValue = this.value;
switch (event.keyCode) {
case PAGE_UP:
this._increment(10);
break;
case PAGE_DOWN:
this._increment(-10);
break;
case END:
this.value = this.max;
break;
case HOME:
this.value = this.min;
break;
case LEFT_ARROW:
// NOTE: For a sighted user it would make more sense that when they press an arrow key on an
// inverted slider the thumb moves in that direction. However for a blind user, nothing
// about the slider indicates that it is inverted. They will expect left to be decrement,
// regardless of how it appears on the screen. For speakers ofRTL languages, they probably
// expect left to mean increment. Therefore we flip the meaning of the side arrow keys for
// RTL. For inverted sliders we prefer a good a11y experience to having it "look right" for
// sighted users, therefore we do not swap the meaning.
this._increment(this._direction == 'rtl' ? 1 : -1);
break;
case UP_ARROW:
this._increment(1);
break;
case RIGHT_ARROW:
// See comment on LEFT_ARROW about the conditions under which we flip the meaning.
this._increment(this._direction == 'rtl' ? -1 : 1);
break;
case DOWN_ARROW:
this._increment(-1);
break;
default:
// Return if the key is not one that we explicitly handle to avoid calling preventDefault on
// it.
return;
}
if (oldValue != this.value) {
this._emitInputEvent();
this._emitChangeEvent();
}
this._isSliding = true;
event.preventDefault();
};
/**
* @return {?}
*/
MatSlider.prototype._onKeyup = function () {
this._isSliding = false;
};
/**
* Increments the slider by the given number of steps (negative number decrements).
* @param {?} numSteps
* @return {?}
*/
MatSlider.prototype._increment = function (numSteps) {
this.value = this._clamp((this.value || 0) + this.step * numSteps, this.min, this.max);
};
/**
* Calculate the new value from the new physical location. The value will always be snapped.
* @param {?} pos
* @return {?}
*/
MatSlider.prototype._updateValueFromPosition = function (pos) {
if (!this._sliderDimensions) {
return;
}
var /** @type {?} */ offset = this.vertical ? this._sliderDimensions.top : this._sliderDimensions.left;
var /** @type {?} */ size = this.vertical ? this._sliderDimensions.height : this._sliderDimensions.width;
var /** @type {?} */ posComponent = this.vertical ? pos.y : pos.x;
// The exact value is calculated from the event and used to find the closest snap value.
var /** @type {?} */ percent = this._clamp((posComponent - offset) / size);
if (this._invertMouseCoords) {
percent = 1 - percent;
}
var /** @type {?} */ exactValue = this._calculateValue(percent);
// This calculation finds the closest step by finding the closest whole number divisible by the
// step relative to the min.
var /** @type {?} */ closestValue = Math.round((exactValue - this.min) / this.step) * this.step + this.min;
// The value needs to snap to the min and max.
this.value = this._clamp(closestValue, this.min, this.max);
};
/**
* Emits a change event if the current value is different from the last emitted value.
* @return {?}
*/
MatSlider.prototype._emitChangeEvent = function () {
this._controlValueAccessorChangeFn(this.value);
this.change.emit(this._createChangeEvent());
};
/**
* Emits an input event when the current value is different from the last emitted value.
* @return {?}
*/
MatSlider.prototype._emitInputEvent = function () {
this.input.emit(this._createChangeEvent());
};
/**
* Updates the amount of space between ticks as a percentage of the width of the slider.
* @return {?}
*/
MatSlider.prototype._updateTickIntervalPercent = function () {
if (!this.tickInterval || !this._sliderDimensions) {
return;
}
if (this.tickInterval == 'auto') {
var /** @type {?} */ trackSize = this.vertical ? this._sliderDimensions.height : this._sliderDimensions.width;
var /** @type {?} */ pixelsPerStep = trackSize * this.step / (this.max - this.min);
var /** @type {?} */ stepsPerTick = Math.ceil(MIN_AUTO_TICK_SEPARATION / pixelsPerStep);
var /** @type {?} */ pixelsPerTick = stepsPerTick * this.step;
this._tickIntervalPercent = pixelsPerTick / trackSize;
}
else {
this._tickIntervalPercent = this.tickInterval * this.step / (this.max - this.min);
}
};
/**
* Creates a slider change object from the specified value.
* @param {?=} value
* @return {?}
*/
MatSlider.prototype._createChangeEvent = function (value) {
if (value === void 0) { value = this.value; }
var /** @type {?} */ event = new MatSliderChange();
event.source = this;
event.value = value;
return event;
};
/**
* Calculates the percentage of the slider that a value is.
* @param {?} value
* @return {?}
*/
MatSlider.prototype._calculatePercentage = function (value) {
return ((value || 0) - this.min) / (this.max - this.min);
};
/**
* Calculates the value a percentage of the slider corresponds to.
* @param {?} percentage
* @return {?}
*/
MatSlider.prototype._calculateValue = function (percentage) {
return this.min + percentage * (this.max - this.min);
};
/**
* Return a number between two numbers.
* @param {?} value
* @param {?=} min
* @param {?=} max
* @return {?}
*/
MatSlider.prototype._clamp = function (value, min, max) {
if (min === void 0) { min = 0; }
if (max === void 0) { max = 1; }
return Math.max(min, Math.min(value, max));
};
/**
* Get the bounding client rect of the slider track element.
* The track is used rather than the native element to ignore the extra space that the thumb can
* take up.
* @return {?}
*/
MatSlider.prototype._getSliderDimensions = function () {
return this._sliderWrapper ? this._sliderWrapper.nativeElement.getBoundingClientRect() : null;
};
/**
* Focuses the native element.
* Currently only used to allow a blur event to fire but will be used with keyboard input later.
* @return {?}
*/
MatSlider.prototype._focusHostElement = function () {
this._elementRef.nativeElement.focus();
};
/**
* Sets the model value. Implemented as part of ControlValueAccessor.
* @param {?} value
* @return {?}
*/
MatSlider.prototype.writeValue = function (value) {
this.value = value;
};
/**
* Registers a callback to eb triggered when the value has changed.
* Implemented as part of ControlValueAccessor.
* @param {?} fn Callback to be registered.
* @return {?}
*/
MatSlider.prototype.registerOnChange = function (fn) {
this._controlValueAccessorChangeFn = fn;
};
/**
* Registers a callback to be triggered when the component is touched.
* Implemented as part of ControlValueAccessor.
* @param {?} fn Callback to be registered.
* @return {?}
*/
MatSlider.prototype.registerOnTouched = function (fn) {
this.onTouched = fn;
};
/**
* Sets whether the component should be disabled.
* Implemented as part of ControlValueAccessor.
* @param {?} isDisabled
* @return {?}
*/
MatSlider.prototype.setDisabledState = function (isDisabled) {
this.disabled = isDisabled;
};
MatSlider.decorators = [
{ type: Component, args: [{selector: 'mat-slider',
exportAs: 'matSlider',
providers: [MAT_SLIDER_VALUE_ACCESSOR],
host: {
'(focus)': '_onFocus()',
'(blur)': '_onBlur()',
'(click)': '_onClick($event)',
'(keydown)': '_onKeydown($event)',
'(keyup)': '_onKeyup()',
'(mouseenter)': '_onMouseenter()',
'(slide)': '_onSlide($event)',
'(slideend)': '_onSlideEnd()',
'(slidestart)': '_onSlideStart($event)',
'class': 'mat-slider',
'role': 'slider',
'tabindex': '0',
'[attr.aria-disabled]': 'disabled',
'[attr.aria-valuemax]': 'max',
'[attr.aria-valuemin]': 'min',
'[attr.aria-valuenow]': 'value',
'[attr.aria-orientation]': 'vertical ? "vertical" : "horizontal"',
'[class.mat-slider-disabled]': 'disabled',
'[class.mat-slider-has-ticks]': 'tickInterval',
'[class.mat-slider-horizontal]': '!vertical',
'[class.mat-slider-axis-inverted]': '_invertAxis',
'[class.mat-slider-sliding]': '_isSliding',
'[class.mat-slider-thumb-label-showing]': 'thumbLabel',
'[class.mat-slider-vertical]': 'vertical',
'[class.mat-slider-min-value]': '_isMinValue',
'[class.mat-slider-hide-last-tick]': 'disabled || _isMinValue && _thumbGap && _invertAxis',
},
template: "<div class=\"mat-slider-wrapper\" #sliderWrapper><div class=\"mat-slider-track-wrapper\"><div class=\"mat-slider-track-background\" [ngStyle]=\"_trackBackgroundStyles\"></div><div class=\"mat-slider-track-fill\" [ngStyle]=\"_trackFillStyles\"></div></div><div class=\"mat-slider-ticks-container\" [ngStyle]=\"_ticksContainerStyles\"><div class=\"mat-slider-ticks\" [ngStyle]=\"_ticksStyles\"></div></div><div class=\"mat-slider-thumb-container\" [ngStyle]=\"_thumbContainerStyles\"><div class=\"mat-slider-focus-ring\"></div><div class=\"mat-slider-thumb\"></div><div class=\"mat-slider-thumb-label\"><span class=\"mat-slider-thumb-label-text\">{{displayValue}}</span></div></div></div>",
styles: [".mat-slider{display:inline-block;position:relative;box-sizing:border-box;padding:8px;outline:0;vertical-align:middle}.mat-slider-wrapper{position:absolute}.mat-slider-track-wrapper{position:absolute;top:0;left:0;overflow:hidden}.mat-slider-track-fill{position:absolute;transform-origin:0 0;transition:transform .4s cubic-bezier(.25,.8,.25,1),background-color .4s cubic-bezier(.25,.8,.25,1)}.mat-slider-track-background{position:absolute;transform-origin:100% 100%;transition:transform .4s cubic-bezier(.25,.8,.25,1),background-color .4s cubic-bezier(.25,.8,.25,1)}.mat-slider-ticks-container{position:absolute;left:0;top:0;overflow:hidden}.mat-slider-ticks{background-repeat:repeat;background-clip:content-box;box-sizing:border-box;opacity:0;transition:opacity .4s cubic-bezier(.25,.8,.25,1)}.mat-slider-thumb-container{position:absolute;z-index:1;transition:transform .4s cubic-bezier(.25,.8,.25,1)}.mat-slider-focus-ring{position:absolute;width:30px;height:30px;border-radius:50%;transform:scale(0);opacity:0;transition:transform .4s cubic-bezier(.25,.8,.25,1),background-color .4s cubic-bezier(.25,.8,.25,1),opacity .4s cubic-bezier(.25,.8,.25,1)}.cdk-keyboard-focused .mat-slider-focus-ring{transform:scale(1);opacity:1}.mat-slider:not(.mat-slider-disabled) .mat-slider-thumb,.mat-slider:not(.mat-slider-disabled) .mat-slider-thumb-label{cursor:-webkit-grab;cursor:grab}.mat-slider-sliding:not(.mat-slider-disabled) .mat-slider-thumb,.mat-slider-sliding:not(.mat-slider-disabled) .mat-slider-thumb-label,.mat-slider:not(.mat-slider-disabled) .mat-slider-thumb-label:active,.mat-slider:not(.mat-slider-disabled) .mat-slider-thumb:active{cursor:-webkit-grabbing;cursor:grabbing}.mat-slider-thumb{position:absolute;right:-10px;bottom:-10px;box-sizing:border-box;width:20px;height:20px;border:3px solid transparent;border-radius:50%;transform:scale(.7);transition:transform .4s cubic-bezier(.25,.8,.25,1),background-color .4s cubic-bezier(.25,.8,.25,1),border-color .4s cubic-bezier(.25,.8,.25,1)}.mat-slider-thumb-label{display:none;align-items:center;justify-content:center;position:absolute;width:28px;height:28px;border-radius:50%;transition:transform .4s cubic-bezier(.25,.8,.25,1),border-radius .4s cubic-bezier(.25,.8,.25,1),background-color .4s cubic-bezier(.25,.8,.25,1)}.mat-slider-thumb-label-text{z-index:1;opacity:0;transition:opacity .4s cubic-bezier(.25,.8,.25,1)}.mat-slider-sliding .mat-slider-thumb-container,.mat-slider-sliding .mat-slider-track-background,.mat-slider-sliding .mat-slider-track-fill{transition-duration:0s}.mat-slider-has-ticks .mat-slider-wrapper::after{content:'';position:absolute;border-width:0;border-style:solid;opacity:0;transition:opacity .4s cubic-bezier(.25,.8,.25,1)}.mat-slider-has-ticks.cdk-focused:not(.mat-slider-hide-last-tick) .mat-slider-wrapper::after,.mat-slider-has-ticks:hover:not(.mat-slider-hide-last-tick) .mat-slider-wrapper::after{opacity:1}.mat-slider-has-ticks.cdk-focused:not(.mat-slider-disabled) .mat-slider-ticks,.mat-slider-has-ticks:hover:not(.mat-slider-disabled) .mat-slider-ticks{opacity:1}.mat-slider-thumb-label-showing .mat-slider-focus-ring{transform:scale(0);opacity:0}.mat-slider-thumb-label-showing .mat-slider-thumb-label{display:flex}.mat-slider-axis-inverted .mat-slider-track-fill{transform-origin:100% 100%}.mat-slider-axis-inverted .mat-slider-track-background{transform-origin:0 0}.mat-slider:not(.mat-slider-disabled).cdk-focused.mat-slider-thumb-label-showing .mat-slider-thumb{transform:scale(0)}.mat-slider:not(.mat-slider-disabled).cdk-focused .mat-slider-thumb-label{border-radius:50% 50% 0}.mat-slider:not(.mat-slider-disabled).cdk-focused .mat-slider-thumb-label-text{opacity:1}.mat-slider:not(.mat-slider-disabled).cdk-mouse-focused .mat-slider-thumb,.mat-slider:not(.mat-slider-disabled).cdk-program-focused .mat-slider-thumb,.mat-slider:not(.mat-slider-disabled).cdk-touch-focused .mat-slider-thumb{border-width:2px;transform:scale(1)}.mat-slider-disabled .mat-slider-focus-ring{transform:scale(0);opacity:0}.mat-slider-disabled .mat-slider-thumb{border-width:4px;transform:scale(.5)}.mat-slider-disabled .mat-slider-thumb-label{display:none}.mat-slider-horizontal{height:48px;min-width:128px}.mat-slider-horizontal .mat-slider-wrapper{height:2px;top:23px;left:8px;right:8px}.mat-slider-horizontal .mat-slider-wrapper::after{height:2px;border-left-width:2px;right:0;top:0}.mat-slider-horizontal .mat-slider-track-wrapper{height:2px;width:100%}.mat-slider-horizontal .mat-slider-track-fill{height:2px;width:100%;transform:scaleX(0)}.mat-slider-horizontal .mat-slider-track-background{height:2px;width:100%;transform:scaleX(1)}.mat-slider-horizontal .mat-slider-ticks-container{height:2px;width:100%}.mat-slider-horizontal .mat-slider-ticks{height:2px;width:100%}.mat-slider-horizontal .mat-slider-thumb-container{width:100%;height:0;top:50%}.mat-slider-horizontal .mat-slider-focus-ring{top:-15px;right:-15px}.mat-slider-horizontal .mat-slider-thumb-label{right:-14px;top:-40px;transform:translateY(26px) scale(.01) rotate(45deg)}.mat-slider-horizontal .mat-slider-thumb-label-text{transform:rotate(-45deg)}.mat-slider-horizontal.cdk-focused .mat-slider-thumb-label{transform:rotate(45deg)}.mat-slider-vertical{width:48px;min-height:128px}.mat-slider-vertical .mat-slider-wrapper{width:2px;top:8px;bottom:8px;left:23px}.mat-slider-vertical .mat-slider-wrapper::after{width:2px;border-top-width:2px;bottom:0;left:0}.mat-slider-vertical .mat-slider-track-wrapper{height:100%;width:2px}.mat-slider-vertical .mat-slider-track-fill{height:100%;width:2px;transform:scaleY(0)}.mat-slider-vertical .mat-slider-track-background{height:100%;width:2px;transform:scaleY(1)}.mat-slider-vertical .mat-slider-ticks-container{width:2px;height:100%}.mat-slider-vertical .mat-slider-focus-ring{bottom:-15px;left:-15px}.mat-slider-vertical .mat-slider-ticks{width:2px;height:100%}.mat-slider-vertical .mat-slider-thumb-container{height:100%;width:0;left:50%}.mat-slider-vertical .mat-slider-thumb-label{bottom:-14px;left:-40px;transform:translateX(26px) scale(.01) rotate(-45deg)}.mat-slider-vertical .mat-slider-thumb-label-text{transform:rotate(45deg)}.mat-slider-vertical.cdk-focused .mat-slider-thumb-label{transform:rotate(-45deg)}[dir=rtl] .mat-slider-wrapper::after{left:0;right:auto}[dir=rtl] .mat-slider-horizontal .mat-slider-track-fill{transform-origin:100% 100%}[dir=rtl] .mat-slider-horizontal .mat-slider-track-background{transform-origin:0 0}[dir=rtl] .mat-slider-horizontal.mat-slider-axis-inverted .mat-slider-track-fill{transform-origin:0 0}[dir=rtl] .mat-slider-horizontal.mat-slider-axis-inverted .mat-slider-track-background{transform-origin:100% 100%}"],
inputs: ['disabled', 'color'],
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
changeDetection: ChangeDetectionStrategy.OnPush,
},] },
];
/**
* @nocollapse
*/
MatSlider.ctorParameters = function () { return [
{ type: Renderer2, },
{ type: ElementRef, },
{ type: FocusMonitor, },
{ type: ChangeDetectorRef, },
{ type: Directionality, decorators: [{ type: Optional },] },
]; };
MatSlider.propDecorators = {
'invert': [{ type: Input },],
'max': [{ type: Input },],
'min': [{ type: Input },],
'step': [{ type: Input },],
'thumbLabel': [{ type: Input },],
'_thumbLabelDeprecated': [{ type: Input, args: ['thumb-label',] },],
'tickInterval': [{ type: Input },],
'_tickIntervalDeprecated': [{ type: Input, args: ['tick-interval',] },],
'value': [{ type: Input },],
'vertical': [{ type: Input },],
'change': [{ type: Output },],
'input': [{ type: Output },],
'_sliderWrapper': [{ type: ViewChild, args: ['sliderWrapper',] },],
};
return MatSlider;
}(_MatSliderMixinBase));
var MatSliderModule = (function () {
function MatSliderModule() {
}
MatSliderModule.decorators = [
{ type: NgModule, args: [{
imports: [CommonModule, MatCommonModule, BidiModule, A11yModule],
exports: [MatSlider, MatCommonModule],
declarations: [MatSlider],
providers: [{ provide: HAMMER_GESTURE_CONFIG, useClass: GestureConfig }]
},] },
];
/**
* @nocollapse
*/
MatSliderModule.ctorParameters = function () { return []; };
return MatSliderModule;
}());
/**
* Generated bundle index. Do not edit.
*/
export { MatSliderModule, MAT_SLIDER_VALUE_ACCESSOR, MatSliderChange, MatSliderBase, _MatSliderMixinBase, MatSlider };
//# sourceMappingURL=slider.es5.js.map