slider.es5.js 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. import { __extends } from 'tslib';
  9. import { FocusMonitor } from '@angular/cdk/a11y';
  10. import { Directionality } from '@angular/cdk/bidi';
  11. import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
  12. import { DOWN_ARROW, END, HOME, LEFT_ARROW, PAGE_DOWN, PAGE_UP, RIGHT_ARROW, UP_ARROW, hasModifierKey } from '@angular/cdk/keycodes';
  13. import { Attribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, forwardRef, Inject, Input, Optional, Output, ViewChild, ViewEncapsulation, NgModule } from '@angular/core';
  14. import { NG_VALUE_ACCESSOR } from '@angular/forms';
  15. import { mixinColor, mixinDisabled, mixinTabIndex, GestureConfig, MatCommonModule } from '@angular/material/core';
  16. import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
  17. import { Subscription } from 'rxjs';
  18. import { CommonModule } from '@angular/common';
  19. import { HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';
  20. /**
  21. * @fileoverview added by tsickle
  22. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  23. */
  24. /**
  25. * Visually, a 30px separation between tick marks looks best. This is very subjective but it is
  26. * the default separation we chose.
  27. * @type {?}
  28. */
  29. var MIN_AUTO_TICK_SEPARATION = 30;
  30. /**
  31. * The thumb gap size for a disabled slider.
  32. * @type {?}
  33. */
  34. var DISABLED_THUMB_GAP = 7;
  35. /**
  36. * The thumb gap size for a non-active slider at its minimum value.
  37. * @type {?}
  38. */
  39. var MIN_VALUE_NONACTIVE_THUMB_GAP = 7;
  40. /**
  41. * The thumb gap size for an active slider at its minimum value.
  42. * @type {?}
  43. */
  44. var MIN_VALUE_ACTIVE_THUMB_GAP = 10;
  45. /**
  46. * Provider Expression that allows mat-slider to register as a ControlValueAccessor.
  47. * This allows it to support [(ngModel)] and [formControl].
  48. * \@docs-private
  49. * @type {?}
  50. */
  51. var MAT_SLIDER_VALUE_ACCESSOR = {
  52. provide: NG_VALUE_ACCESSOR,
  53. useExisting: forwardRef((/**
  54. * @return {?}
  55. */
  56. function () { return MatSlider; })),
  57. multi: true
  58. };
  59. /**
  60. * A simple change event emitted by the MatSlider component.
  61. */
  62. var /**
  63. * A simple change event emitted by the MatSlider component.
  64. */
  65. MatSliderChange = /** @class */ (function () {
  66. function MatSliderChange() {
  67. }
  68. return MatSliderChange;
  69. }());
  70. // Boilerplate for applying mixins to MatSlider.
  71. /**
  72. * \@docs-private
  73. */
  74. var
  75. // Boilerplate for applying mixins to MatSlider.
  76. /**
  77. * \@docs-private
  78. */
  79. MatSliderBase = /** @class */ (function () {
  80. function MatSliderBase(_elementRef) {
  81. this._elementRef = _elementRef;
  82. }
  83. return MatSliderBase;
  84. }());
  85. /** @type {?} */
  86. var _MatSliderMixinBase = mixinTabIndex(mixinColor(mixinDisabled(MatSliderBase), 'accent'));
  87. /**
  88. * Allows users to select from a range of values by moving the slider thumb. It is similar in
  89. * behavior to the native `<input type="range">` element.
  90. */
  91. var MatSlider = /** @class */ (function (_super) {
  92. __extends(MatSlider, _super);
  93. function MatSlider(elementRef, _focusMonitor, _changeDetectorRef, _dir, tabIndex, _animationMode) {
  94. var _this = _super.call(this, elementRef) || this;
  95. _this._focusMonitor = _focusMonitor;
  96. _this._changeDetectorRef = _changeDetectorRef;
  97. _this._dir = _dir;
  98. _this._animationMode = _animationMode;
  99. _this._invert = false;
  100. _this._max = 100;
  101. _this._min = 0;
  102. _this._step = 1;
  103. _this._thumbLabel = false;
  104. _this._tickInterval = 0;
  105. _this._value = null;
  106. _this._vertical = false;
  107. /**
  108. * Event emitted when the slider value has changed.
  109. */
  110. _this.change = new EventEmitter();
  111. /**
  112. * Event emitted when the slider thumb moves.
  113. */
  114. _this.input = new EventEmitter();
  115. /**
  116. * Emits when the raw value of the slider changes. This is here primarily
  117. * to facilitate the two-way binding for the `value` input.
  118. * \@docs-private
  119. */
  120. _this.valueChange = new EventEmitter();
  121. /**
  122. * onTouch function registered via registerOnTouch (ControlValueAccessor).
  123. */
  124. _this.onTouched = (/**
  125. * @return {?}
  126. */
  127. function () { });
  128. _this._percent = 0;
  129. /**
  130. * Whether or not the thumb is sliding.
  131. * Used to determine if there should be a transition for the thumb and fill track.
  132. */
  133. _this._isSliding = false;
  134. /**
  135. * Whether or not the slider is active (clicked or sliding).
  136. * Used to shrink and grow the thumb as according to the Material Design spec.
  137. */
  138. _this._isActive = false;
  139. /**
  140. * The size of a tick interval as a percentage of the size of the track.
  141. */
  142. _this._tickIntervalPercent = 0;
  143. /**
  144. * The dimensions of the slider.
  145. */
  146. _this._sliderDimensions = null;
  147. _this._controlValueAccessorChangeFn = (/**
  148. * @return {?}
  149. */
  150. function () { });
  151. /**
  152. * Subscription to the Directionality change EventEmitter.
  153. */
  154. _this._dirChangeSubscription = Subscription.EMPTY;
  155. _this.tabIndex = parseInt(tabIndex) || 0;
  156. return _this;
  157. }
  158. Object.defineProperty(MatSlider.prototype, "invert", {
  159. /** Whether the slider is inverted. */
  160. get: /**
  161. * Whether the slider is inverted.
  162. * @return {?}
  163. */
  164. function () { return this._invert; },
  165. set: /**
  166. * @param {?} value
  167. * @return {?}
  168. */
  169. function (value) {
  170. this._invert = coerceBooleanProperty(value);
  171. },
  172. enumerable: true,
  173. configurable: true
  174. });
  175. Object.defineProperty(MatSlider.prototype, "max", {
  176. /** The maximum value that the slider can have. */
  177. get: /**
  178. * The maximum value that the slider can have.
  179. * @return {?}
  180. */
  181. function () { return this._max; },
  182. set: /**
  183. * @param {?} v
  184. * @return {?}
  185. */
  186. function (v) {
  187. this._max = coerceNumberProperty(v, this._max);
  188. this._percent = this._calculatePercentage(this._value);
  189. // Since this also modifies the percentage, we need to let the change detection know.
  190. this._changeDetectorRef.markForCheck();
  191. },
  192. enumerable: true,
  193. configurable: true
  194. });
  195. Object.defineProperty(MatSlider.prototype, "min", {
  196. /** The minimum value that the slider can have. */
  197. get: /**
  198. * The minimum value that the slider can have.
  199. * @return {?}
  200. */
  201. function () { return this._min; },
  202. set: /**
  203. * @param {?} v
  204. * @return {?}
  205. */
  206. function (v) {
  207. this._min = coerceNumberProperty(v, this._min);
  208. // If the value wasn't explicitly set by the user, set it to the min.
  209. if (this._value === null) {
  210. this.value = this._min;
  211. }
  212. this._percent = this._calculatePercentage(this._value);
  213. // Since this also modifies the percentage, we need to let the change detection know.
  214. this._changeDetectorRef.markForCheck();
  215. },
  216. enumerable: true,
  217. configurable: true
  218. });
  219. Object.defineProperty(MatSlider.prototype, "step", {
  220. /** The values at which the thumb will snap. */
  221. get: /**
  222. * The values at which the thumb will snap.
  223. * @return {?}
  224. */
  225. function () { return this._step; },
  226. set: /**
  227. * @param {?} v
  228. * @return {?}
  229. */
  230. function (v) {
  231. this._step = coerceNumberProperty(v, this._step);
  232. if (this._step % 1 !== 0) {
  233. this._roundToDecimal = (/** @type {?} */ (this._step.toString().split('.').pop())).length;
  234. }
  235. // Since this could modify the label, we need to notify the change detection.
  236. this._changeDetectorRef.markForCheck();
  237. },
  238. enumerable: true,
  239. configurable: true
  240. });
  241. Object.defineProperty(MatSlider.prototype, "thumbLabel", {
  242. /** Whether or not to show the thumb label. */
  243. get: /**
  244. * Whether or not to show the thumb label.
  245. * @return {?}
  246. */
  247. function () { return this._thumbLabel; },
  248. set: /**
  249. * @param {?} value
  250. * @return {?}
  251. */
  252. function (value) { this._thumbLabel = coerceBooleanProperty(value); },
  253. enumerable: true,
  254. configurable: true
  255. });
  256. Object.defineProperty(MatSlider.prototype, "tickInterval", {
  257. /**
  258. * How often to show ticks. Relative to the step so that a tick always appears on a step.
  259. * Ex: Tick interval of 4 with a step of 3 will draw a tick every 4 steps (every 12 values).
  260. */
  261. get: /**
  262. * How often to show ticks. Relative to the step so that a tick always appears on a step.
  263. * Ex: Tick interval of 4 with a step of 3 will draw a tick every 4 steps (every 12 values).
  264. * @return {?}
  265. */
  266. function () { return this._tickInterval; },
  267. set: /**
  268. * @param {?} value
  269. * @return {?}
  270. */
  271. function (value) {
  272. if (value === 'auto') {
  273. this._tickInterval = 'auto';
  274. }
  275. else if (typeof value === 'number' || typeof value === 'string') {
  276. this._tickInterval = coerceNumberProperty(value, (/** @type {?} */ (this._tickInterval)));
  277. }
  278. else {
  279. this._tickInterval = 0;
  280. }
  281. },
  282. enumerable: true,
  283. configurable: true
  284. });
  285. Object.defineProperty(MatSlider.prototype, "value", {
  286. /** Value of the slider. */
  287. get: /**
  288. * Value of the slider.
  289. * @return {?}
  290. */
  291. function () {
  292. // If the value needs to be read and it is still uninitialized, initialize it to the min.
  293. if (this._value === null) {
  294. this.value = this._min;
  295. }
  296. return this._value;
  297. },
  298. set: /**
  299. * @param {?} v
  300. * @return {?}
  301. */
  302. function (v) {
  303. if (v !== this._value) {
  304. /** @type {?} */
  305. var value = coerceNumberProperty(v);
  306. // While incrementing by a decimal we can end up with values like 33.300000000000004.
  307. // Truncate it to ensure that it matches the label and to make it easier to work with.
  308. if (this._roundToDecimal) {
  309. value = parseFloat(value.toFixed(this._roundToDecimal));
  310. }
  311. this._value = value;
  312. this._percent = this._calculatePercentage(this._value);
  313. // Since this also modifies the percentage, we need to let the change detection know.
  314. this._changeDetectorRef.markForCheck();
  315. }
  316. },
  317. enumerable: true,
  318. configurable: true
  319. });
  320. Object.defineProperty(MatSlider.prototype, "vertical", {
  321. /** Whether the slider is vertical. */
  322. get: /**
  323. * Whether the slider is vertical.
  324. * @return {?}
  325. */
  326. function () { return this._vertical; },
  327. set: /**
  328. * @param {?} value
  329. * @return {?}
  330. */
  331. function (value) {
  332. this._vertical = coerceBooleanProperty(value);
  333. },
  334. enumerable: true,
  335. configurable: true
  336. });
  337. Object.defineProperty(MatSlider.prototype, "displayValue", {
  338. /** The value to be used for display purposes. */
  339. get: /**
  340. * The value to be used for display purposes.
  341. * @return {?}
  342. */
  343. function () {
  344. if (this.displayWith) {
  345. return this.displayWith(this.value);
  346. }
  347. // Note that this could be improved further by rounding something like 0.999 to 1 or
  348. // 0.899 to 0.9, however it is very performance sensitive, because it gets called on
  349. // every change detection cycle.
  350. if (this._roundToDecimal && this.value && this.value % 1 !== 0) {
  351. return this.value.toFixed(this._roundToDecimal);
  352. }
  353. return this.value || 0;
  354. },
  355. enumerable: true,
  356. configurable: true
  357. });
  358. /** set focus to the host element */
  359. /**
  360. * set focus to the host element
  361. * @param {?=} options
  362. * @return {?}
  363. */
  364. MatSlider.prototype.focus = /**
  365. * set focus to the host element
  366. * @param {?=} options
  367. * @return {?}
  368. */
  369. function (options) {
  370. this._focusHostElement(options);
  371. };
  372. /** blur the host element */
  373. /**
  374. * blur the host element
  375. * @return {?}
  376. */
  377. MatSlider.prototype.blur = /**
  378. * blur the host element
  379. * @return {?}
  380. */
  381. function () {
  382. this._blurHostElement();
  383. };
  384. Object.defineProperty(MatSlider.prototype, "percent", {
  385. /** The percentage of the slider that coincides with the value. */
  386. get: /**
  387. * The percentage of the slider that coincides with the value.
  388. * @return {?}
  389. */
  390. function () { return this._clamp(this._percent); },
  391. enumerable: true,
  392. configurable: true
  393. });
  394. Object.defineProperty(MatSlider.prototype, "_invertAxis", {
  395. /**
  396. * Whether the axis of the slider is inverted.
  397. * (i.e. whether moving the thumb in the positive x or y direction decreases the slider's value).
  398. */
  399. get: /**
  400. * Whether the axis of the slider is inverted.
  401. * (i.e. whether moving the thumb in the positive x or y direction decreases the slider's value).
  402. * @return {?}
  403. */
  404. function () {
  405. // Standard non-inverted mode for a vertical slider should be dragging the thumb from bottom to
  406. // top. However from a y-axis standpoint this is inverted.
  407. return this.vertical ? !this.invert : this.invert;
  408. },
  409. enumerable: true,
  410. configurable: true
  411. });
  412. Object.defineProperty(MatSlider.prototype, "_isMinValue", {
  413. /** Whether the slider is at its minimum value. */
  414. get: /**
  415. * Whether the slider is at its minimum value.
  416. * @return {?}
  417. */
  418. function () {
  419. return this.percent === 0;
  420. },
  421. enumerable: true,
  422. configurable: true
  423. });
  424. Object.defineProperty(MatSlider.prototype, "_thumbGap", {
  425. /**
  426. * The amount of space to leave between the slider thumb and the track fill & track background
  427. * elements.
  428. */
  429. get: /**
  430. * The amount of space to leave between the slider thumb and the track fill & track background
  431. * elements.
  432. * @return {?}
  433. */
  434. function () {
  435. if (this.disabled) {
  436. return DISABLED_THUMB_GAP;
  437. }
  438. if (this._isMinValue && !this.thumbLabel) {
  439. return this._isActive ? MIN_VALUE_ACTIVE_THUMB_GAP : MIN_VALUE_NONACTIVE_THUMB_GAP;
  440. }
  441. return 0;
  442. },
  443. enumerable: true,
  444. configurable: true
  445. });
  446. Object.defineProperty(MatSlider.prototype, "_trackBackgroundStyles", {
  447. /** CSS styles for the track background element. */
  448. get: /**
  449. * CSS styles for the track background element.
  450. * @return {?}
  451. */
  452. function () {
  453. /** @type {?} */
  454. var axis = this.vertical ? 'Y' : 'X';
  455. /** @type {?} */
  456. var scale = this.vertical ? "1, " + (1 - this.percent) + ", 1" : 1 - this.percent + ", 1, 1";
  457. /** @type {?} */
  458. var sign = this._shouldInvertMouseCoords() ? '-' : '';
  459. return {
  460. // scale3d avoids some rendering issues in Chrome. See #12071.
  461. transform: "translate" + axis + "(" + sign + this._thumbGap + "px) scale3d(" + scale + ")"
  462. };
  463. },
  464. enumerable: true,
  465. configurable: true
  466. });
  467. Object.defineProperty(MatSlider.prototype, "_trackFillStyles", {
  468. /** CSS styles for the track fill element. */
  469. get: /**
  470. * CSS styles for the track fill element.
  471. * @return {?}
  472. */
  473. function () {
  474. /** @type {?} */
  475. var axis = this.vertical ? 'Y' : 'X';
  476. /** @type {?} */
  477. var scale = this.vertical ? "1, " + this.percent + ", 1" : this.percent + ", 1, 1";
  478. /** @type {?} */
  479. var sign = this._shouldInvertMouseCoords() ? '' : '-';
  480. return {
  481. // scale3d avoids some rendering issues in Chrome. See #12071.
  482. transform: "translate" + axis + "(" + sign + this._thumbGap + "px) scale3d(" + scale + ")"
  483. };
  484. },
  485. enumerable: true,
  486. configurable: true
  487. });
  488. Object.defineProperty(MatSlider.prototype, "_ticksContainerStyles", {
  489. /** CSS styles for the ticks container element. */
  490. get: /**
  491. * CSS styles for the ticks container element.
  492. * @return {?}
  493. */
  494. function () {
  495. /** @type {?} */
  496. var axis = this.vertical ? 'Y' : 'X';
  497. // For a horizontal slider in RTL languages we push the ticks container off the left edge
  498. // instead of the right edge to avoid causing a horizontal scrollbar to appear.
  499. /** @type {?} */
  500. var sign = !this.vertical && this._getDirection() == 'rtl' ? '' : '-';
  501. /** @type {?} */
  502. var offset = this._tickIntervalPercent / 2 * 100;
  503. return {
  504. 'transform': "translate" + axis + "(" + sign + offset + "%)"
  505. };
  506. },
  507. enumerable: true,
  508. configurable: true
  509. });
  510. Object.defineProperty(MatSlider.prototype, "_ticksStyles", {
  511. /** CSS styles for the ticks element. */
  512. get: /**
  513. * CSS styles for the ticks element.
  514. * @return {?}
  515. */
  516. function () {
  517. /** @type {?} */
  518. var tickSize = this._tickIntervalPercent * 100;
  519. /** @type {?} */
  520. var backgroundSize = this.vertical ? "2px " + tickSize + "%" : tickSize + "% 2px";
  521. /** @type {?} */
  522. var axis = this.vertical ? 'Y' : 'X';
  523. // Depending on the direction we pushed the ticks container, push the ticks the opposite
  524. // direction to re-center them but clip off the end edge. In RTL languages we need to flip the
  525. // ticks 180 degrees so we're really cutting off the end edge abd not the start.
  526. /** @type {?} */
  527. var sign = !this.vertical && this._getDirection() == 'rtl' ? '-' : '';
  528. /** @type {?} */
  529. var rotate = !this.vertical && this._getDirection() == 'rtl' ? ' rotate(180deg)' : '';
  530. /** @type {?} */
  531. var styles = {
  532. 'backgroundSize': backgroundSize,
  533. // Without translateZ ticks sometimes jitter as the slider moves on Chrome & Firefox.
  534. 'transform': "translateZ(0) translate" + axis + "(" + sign + tickSize / 2 + "%)" + rotate
  535. };
  536. if (this._isMinValue && this._thumbGap) {
  537. /** @type {?} */
  538. var side = this.vertical ?
  539. (this._invertAxis ? 'Bottom' : 'Top') :
  540. (this._invertAxis ? 'Right' : 'Left');
  541. styles["padding" + side] = this._thumbGap + "px";
  542. }
  543. return styles;
  544. },
  545. enumerable: true,
  546. configurable: true
  547. });
  548. Object.defineProperty(MatSlider.prototype, "_thumbContainerStyles", {
  549. get: /**
  550. * @return {?}
  551. */
  552. function () {
  553. /** @type {?} */
  554. var axis = this.vertical ? 'Y' : 'X';
  555. // For a horizontal slider in RTL languages we push the thumb container off the left edge
  556. // instead of the right edge to avoid causing a horizontal scrollbar to appear.
  557. /** @type {?} */
  558. var invertOffset = (this._getDirection() == 'rtl' && !this.vertical) ? !this._invertAxis : this._invertAxis;
  559. /** @type {?} */
  560. var offset = (invertOffset ? this.percent : 1 - this.percent) * 100;
  561. return {
  562. 'transform': "translate" + axis + "(-" + offset + "%)"
  563. };
  564. },
  565. enumerable: true,
  566. configurable: true
  567. });
  568. /**
  569. * Whether mouse events should be converted to a slider position by calculating their distance
  570. * from the right or bottom edge of the slider as opposed to the top or left.
  571. */
  572. /**
  573. * Whether mouse events should be converted to a slider position by calculating their distance
  574. * from the right or bottom edge of the slider as opposed to the top or left.
  575. * @private
  576. * @return {?}
  577. */
  578. MatSlider.prototype._shouldInvertMouseCoords = /**
  579. * Whether mouse events should be converted to a slider position by calculating their distance
  580. * from the right or bottom edge of the slider as opposed to the top or left.
  581. * @private
  582. * @return {?}
  583. */
  584. function () {
  585. return (this._getDirection() == 'rtl' && !this.vertical) ? !this._invertAxis : this._invertAxis;
  586. };
  587. /** The language direction for this slider element. */
  588. /**
  589. * The language direction for this slider element.
  590. * @private
  591. * @return {?}
  592. */
  593. MatSlider.prototype._getDirection = /**
  594. * The language direction for this slider element.
  595. * @private
  596. * @return {?}
  597. */
  598. function () {
  599. return (this._dir && this._dir.value == 'rtl') ? 'rtl' : 'ltr';
  600. };
  601. /**
  602. * @return {?}
  603. */
  604. MatSlider.prototype.ngOnInit = /**
  605. * @return {?}
  606. */
  607. function () {
  608. var _this = this;
  609. this._focusMonitor
  610. .monitor(this._elementRef, true)
  611. .subscribe((/**
  612. * @param {?} origin
  613. * @return {?}
  614. */
  615. function (origin) {
  616. _this._isActive = !!origin && origin !== 'keyboard';
  617. _this._changeDetectorRef.detectChanges();
  618. }));
  619. if (this._dir) {
  620. this._dirChangeSubscription = this._dir.change.subscribe((/**
  621. * @return {?}
  622. */
  623. function () {
  624. _this._changeDetectorRef.markForCheck();
  625. }));
  626. }
  627. };
  628. /**
  629. * @return {?}
  630. */
  631. MatSlider.prototype.ngOnDestroy = /**
  632. * @return {?}
  633. */
  634. function () {
  635. this._focusMonitor.stopMonitoring(this._elementRef);
  636. this._dirChangeSubscription.unsubscribe();
  637. };
  638. /**
  639. * @return {?}
  640. */
  641. MatSlider.prototype._onMouseenter = /**
  642. * @return {?}
  643. */
  644. function () {
  645. if (this.disabled) {
  646. return;
  647. }
  648. // We save the dimensions of the slider here so we can use them to update the spacing of the
  649. // ticks and determine where on the slider click and slide events happen.
  650. this._sliderDimensions = this._getSliderDimensions();
  651. this._updateTickIntervalPercent();
  652. };
  653. /**
  654. * @param {?} event
  655. * @return {?}
  656. */
  657. MatSlider.prototype._onMousedown = /**
  658. * @param {?} event
  659. * @return {?}
  660. */
  661. function (event) {
  662. // Don't do anything if the slider is disabled or the
  663. // user is using anything other than the main mouse button.
  664. if (this.disabled || event.button !== 0) {
  665. return;
  666. }
  667. /** @type {?} */
  668. var oldValue = this.value;
  669. this._isSliding = false;
  670. this._focusHostElement();
  671. this._updateValueFromPosition({ x: event.clientX, y: event.clientY });
  672. // Emit a change and input event if the value changed.
  673. if (oldValue != this.value) {
  674. this._emitInputEvent();
  675. this._emitChangeEvent();
  676. }
  677. };
  678. /**
  679. * @param {?} event
  680. * @return {?}
  681. */
  682. MatSlider.prototype._onSlide = /**
  683. * @param {?} event
  684. * @return {?}
  685. */
  686. function (event) {
  687. if (this.disabled) {
  688. return;
  689. }
  690. // The slide start event sometimes fails to fire on iOS, so if we're not already in the sliding
  691. // state, call the slide start handler manually.
  692. if (!this._isSliding) {
  693. this._onSlideStart(null);
  694. }
  695. // Prevent the slide from selecting anything else.
  696. event.preventDefault();
  697. /** @type {?} */
  698. var oldValue = this.value;
  699. this._updateValueFromPosition({ x: event.center.x, y: event.center.y });
  700. // Native range elements always emit `input` events when the value changed while sliding.
  701. if (oldValue != this.value) {
  702. this._emitInputEvent();
  703. }
  704. };
  705. /**
  706. * @param {?} event
  707. * @return {?}
  708. */
  709. MatSlider.prototype._onSlideStart = /**
  710. * @param {?} event
  711. * @return {?}
  712. */
  713. function (event) {
  714. if (this.disabled || this._isSliding) {
  715. return;
  716. }
  717. // Simulate mouseenter in case this is a mobile device.
  718. this._onMouseenter();
  719. this._isSliding = true;
  720. this._focusHostElement();
  721. this._valueOnSlideStart = this.value;
  722. if (event) {
  723. this._updateValueFromPosition({ x: event.center.x, y: event.center.y });
  724. event.preventDefault();
  725. }
  726. };
  727. /**
  728. * @return {?}
  729. */
  730. MatSlider.prototype._onSlideEnd = /**
  731. * @return {?}
  732. */
  733. function () {
  734. this._isSliding = false;
  735. if (this._valueOnSlideStart != this.value && !this.disabled) {
  736. this._emitChangeEvent();
  737. }
  738. this._valueOnSlideStart = null;
  739. };
  740. /**
  741. * @return {?}
  742. */
  743. MatSlider.prototype._onFocus = /**
  744. * @return {?}
  745. */
  746. function () {
  747. // We save the dimensions of the slider here so we can use them to update the spacing of the
  748. // ticks and determine where on the slider click and slide events happen.
  749. this._sliderDimensions = this._getSliderDimensions();
  750. this._updateTickIntervalPercent();
  751. };
  752. /**
  753. * @return {?}
  754. */
  755. MatSlider.prototype._onBlur = /**
  756. * @return {?}
  757. */
  758. function () {
  759. this.onTouched();
  760. };
  761. /**
  762. * @param {?} event
  763. * @return {?}
  764. */
  765. MatSlider.prototype._onKeydown = /**
  766. * @param {?} event
  767. * @return {?}
  768. */
  769. function (event) {
  770. if (this.disabled || hasModifierKey(event)) {
  771. return;
  772. }
  773. /** @type {?} */
  774. var oldValue = this.value;
  775. switch (event.keyCode) {
  776. case PAGE_UP:
  777. this._increment(10);
  778. break;
  779. case PAGE_DOWN:
  780. this._increment(-10);
  781. break;
  782. case END:
  783. this.value = this.max;
  784. break;
  785. case HOME:
  786. this.value = this.min;
  787. break;
  788. case LEFT_ARROW:
  789. // NOTE: For a sighted user it would make more sense that when they press an arrow key on an
  790. // inverted slider the thumb moves in that direction. However for a blind user, nothing
  791. // about the slider indicates that it is inverted. They will expect left to be decrement,
  792. // regardless of how it appears on the screen. For speakers ofRTL languages, they probably
  793. // expect left to mean increment. Therefore we flip the meaning of the side arrow keys for
  794. // RTL. For inverted sliders we prefer a good a11y experience to having it "look right" for
  795. // sighted users, therefore we do not swap the meaning.
  796. this._increment(this._getDirection() == 'rtl' ? 1 : -1);
  797. break;
  798. case UP_ARROW:
  799. this._increment(1);
  800. break;
  801. case RIGHT_ARROW:
  802. // See comment on LEFT_ARROW about the conditions under which we flip the meaning.
  803. this._increment(this._getDirection() == 'rtl' ? -1 : 1);
  804. break;
  805. case DOWN_ARROW:
  806. this._increment(-1);
  807. break;
  808. default:
  809. // Return if the key is not one that we explicitly handle to avoid calling preventDefault on
  810. // it.
  811. return;
  812. }
  813. if (oldValue != this.value) {
  814. this._emitInputEvent();
  815. this._emitChangeEvent();
  816. }
  817. this._isSliding = true;
  818. event.preventDefault();
  819. };
  820. /**
  821. * @return {?}
  822. */
  823. MatSlider.prototype._onKeyup = /**
  824. * @return {?}
  825. */
  826. function () {
  827. this._isSliding = false;
  828. };
  829. /** Increments the slider by the given number of steps (negative number decrements). */
  830. /**
  831. * Increments the slider by the given number of steps (negative number decrements).
  832. * @private
  833. * @param {?} numSteps
  834. * @return {?}
  835. */
  836. MatSlider.prototype._increment = /**
  837. * Increments the slider by the given number of steps (negative number decrements).
  838. * @private
  839. * @param {?} numSteps
  840. * @return {?}
  841. */
  842. function (numSteps) {
  843. this.value = this._clamp((this.value || 0) + this.step * numSteps, this.min, this.max);
  844. };
  845. /** Calculate the new value from the new physical location. The value will always be snapped. */
  846. /**
  847. * Calculate the new value from the new physical location. The value will always be snapped.
  848. * @private
  849. * @param {?} pos
  850. * @return {?}
  851. */
  852. MatSlider.prototype._updateValueFromPosition = /**
  853. * Calculate the new value from the new physical location. The value will always be snapped.
  854. * @private
  855. * @param {?} pos
  856. * @return {?}
  857. */
  858. function (pos) {
  859. if (!this._sliderDimensions) {
  860. return;
  861. }
  862. /** @type {?} */
  863. var offset = this.vertical ? this._sliderDimensions.top : this._sliderDimensions.left;
  864. /** @type {?} */
  865. var size = this.vertical ? this._sliderDimensions.height : this._sliderDimensions.width;
  866. /** @type {?} */
  867. var posComponent = this.vertical ? pos.y : pos.x;
  868. // The exact value is calculated from the event and used to find the closest snap value.
  869. /** @type {?} */
  870. var percent = this._clamp((posComponent - offset) / size);
  871. if (this._shouldInvertMouseCoords()) {
  872. percent = 1 - percent;
  873. }
  874. // Since the steps may not divide cleanly into the max value, if the user
  875. // slid to 0 or 100 percent, we jump to the min/max value. This approach
  876. // is slightly more intuitive than using `Math.ceil` below, because it
  877. // follows the user's pointer closer.
  878. if (percent === 0) {
  879. this.value = this.min;
  880. }
  881. else if (percent === 1) {
  882. this.value = this.max;
  883. }
  884. else {
  885. /** @type {?} */
  886. var exactValue = this._calculateValue(percent);
  887. // This calculation finds the closest step by finding the closest
  888. // whole number divisible by the step relative to the min.
  889. /** @type {?} */
  890. var closestValue = Math.round((exactValue - this.min) / this.step) * this.step + this.min;
  891. // The value needs to snap to the min and max.
  892. this.value = this._clamp(closestValue, this.min, this.max);
  893. }
  894. };
  895. /** Emits a change event if the current value is different from the last emitted value. */
  896. /**
  897. * Emits a change event if the current value is different from the last emitted value.
  898. * @private
  899. * @return {?}
  900. */
  901. MatSlider.prototype._emitChangeEvent = /**
  902. * Emits a change event if the current value is different from the last emitted value.
  903. * @private
  904. * @return {?}
  905. */
  906. function () {
  907. this._controlValueAccessorChangeFn(this.value);
  908. this.valueChange.emit(this.value);
  909. this.change.emit(this._createChangeEvent());
  910. };
  911. /** Emits an input event when the current value is different from the last emitted value. */
  912. /**
  913. * Emits an input event when the current value is different from the last emitted value.
  914. * @private
  915. * @return {?}
  916. */
  917. MatSlider.prototype._emitInputEvent = /**
  918. * Emits an input event when the current value is different from the last emitted value.
  919. * @private
  920. * @return {?}
  921. */
  922. function () {
  923. this.input.emit(this._createChangeEvent());
  924. };
  925. /** Updates the amount of space between ticks as a percentage of the width of the slider. */
  926. /**
  927. * Updates the amount of space between ticks as a percentage of the width of the slider.
  928. * @private
  929. * @return {?}
  930. */
  931. MatSlider.prototype._updateTickIntervalPercent = /**
  932. * Updates the amount of space between ticks as a percentage of the width of the slider.
  933. * @private
  934. * @return {?}
  935. */
  936. function () {
  937. if (!this.tickInterval || !this._sliderDimensions) {
  938. return;
  939. }
  940. if (this.tickInterval == 'auto') {
  941. /** @type {?} */
  942. var trackSize = this.vertical ? this._sliderDimensions.height : this._sliderDimensions.width;
  943. /** @type {?} */
  944. var pixelsPerStep = trackSize * this.step / (this.max - this.min);
  945. /** @type {?} */
  946. var stepsPerTick = Math.ceil(MIN_AUTO_TICK_SEPARATION / pixelsPerStep);
  947. /** @type {?} */
  948. var pixelsPerTick = stepsPerTick * this.step;
  949. this._tickIntervalPercent = pixelsPerTick / trackSize;
  950. }
  951. else {
  952. this._tickIntervalPercent = this.tickInterval * this.step / (this.max - this.min);
  953. }
  954. };
  955. /** Creates a slider change object from the specified value. */
  956. /**
  957. * Creates a slider change object from the specified value.
  958. * @private
  959. * @param {?=} value
  960. * @return {?}
  961. */
  962. MatSlider.prototype._createChangeEvent = /**
  963. * Creates a slider change object from the specified value.
  964. * @private
  965. * @param {?=} value
  966. * @return {?}
  967. */
  968. function (value) {
  969. if (value === void 0) { value = this.value; }
  970. /** @type {?} */
  971. var event = new MatSliderChange();
  972. event.source = this;
  973. event.value = value;
  974. return event;
  975. };
  976. /** Calculates the percentage of the slider that a value is. */
  977. /**
  978. * Calculates the percentage of the slider that a value is.
  979. * @private
  980. * @param {?} value
  981. * @return {?}
  982. */
  983. MatSlider.prototype._calculatePercentage = /**
  984. * Calculates the percentage of the slider that a value is.
  985. * @private
  986. * @param {?} value
  987. * @return {?}
  988. */
  989. function (value) {
  990. return ((value || 0) - this.min) / (this.max - this.min);
  991. };
  992. /** Calculates the value a percentage of the slider corresponds to. */
  993. /**
  994. * Calculates the value a percentage of the slider corresponds to.
  995. * @private
  996. * @param {?} percentage
  997. * @return {?}
  998. */
  999. MatSlider.prototype._calculateValue = /**
  1000. * Calculates the value a percentage of the slider corresponds to.
  1001. * @private
  1002. * @param {?} percentage
  1003. * @return {?}
  1004. */
  1005. function (percentage) {
  1006. return this.min + percentage * (this.max - this.min);
  1007. };
  1008. /** Return a number between two numbers. */
  1009. /**
  1010. * Return a number between two numbers.
  1011. * @private
  1012. * @param {?} value
  1013. * @param {?=} min
  1014. * @param {?=} max
  1015. * @return {?}
  1016. */
  1017. MatSlider.prototype._clamp = /**
  1018. * Return a number between two numbers.
  1019. * @private
  1020. * @param {?} value
  1021. * @param {?=} min
  1022. * @param {?=} max
  1023. * @return {?}
  1024. */
  1025. function (value, min, max) {
  1026. if (min === void 0) { min = 0; }
  1027. if (max === void 0) { max = 1; }
  1028. return Math.max(min, Math.min(value, max));
  1029. };
  1030. /**
  1031. * Get the bounding client rect of the slider track element.
  1032. * The track is used rather than the native element to ignore the extra space that the thumb can
  1033. * take up.
  1034. */
  1035. /**
  1036. * Get the bounding client rect of the slider track element.
  1037. * The track is used rather than the native element to ignore the extra space that the thumb can
  1038. * take up.
  1039. * @private
  1040. * @return {?}
  1041. */
  1042. MatSlider.prototype._getSliderDimensions = /**
  1043. * Get the bounding client rect of the slider track element.
  1044. * The track is used rather than the native element to ignore the extra space that the thumb can
  1045. * take up.
  1046. * @private
  1047. * @return {?}
  1048. */
  1049. function () {
  1050. return this._sliderWrapper ? this._sliderWrapper.nativeElement.getBoundingClientRect() : null;
  1051. };
  1052. /**
  1053. * Focuses the native element.
  1054. * Currently only used to allow a blur event to fire but will be used with keyboard input later.
  1055. */
  1056. /**
  1057. * Focuses the native element.
  1058. * Currently only used to allow a blur event to fire but will be used with keyboard input later.
  1059. * @private
  1060. * @param {?=} options
  1061. * @return {?}
  1062. */
  1063. MatSlider.prototype._focusHostElement = /**
  1064. * Focuses the native element.
  1065. * Currently only used to allow a blur event to fire but will be used with keyboard input later.
  1066. * @private
  1067. * @param {?=} options
  1068. * @return {?}
  1069. */
  1070. function (options) {
  1071. this._elementRef.nativeElement.focus(options);
  1072. };
  1073. /** Blurs the native element. */
  1074. /**
  1075. * Blurs the native element.
  1076. * @private
  1077. * @return {?}
  1078. */
  1079. MatSlider.prototype._blurHostElement = /**
  1080. * Blurs the native element.
  1081. * @private
  1082. * @return {?}
  1083. */
  1084. function () {
  1085. this._elementRef.nativeElement.blur();
  1086. };
  1087. /**
  1088. * Sets the model value. Implemented as part of ControlValueAccessor.
  1089. * @param value
  1090. */
  1091. /**
  1092. * Sets the model value. Implemented as part of ControlValueAccessor.
  1093. * @param {?} value
  1094. * @return {?}
  1095. */
  1096. MatSlider.prototype.writeValue = /**
  1097. * Sets the model value. Implemented as part of ControlValueAccessor.
  1098. * @param {?} value
  1099. * @return {?}
  1100. */
  1101. function (value) {
  1102. this.value = value;
  1103. };
  1104. /**
  1105. * Registers a callback to be triggered when the value has changed.
  1106. * Implemented as part of ControlValueAccessor.
  1107. * @param fn Callback to be registered.
  1108. */
  1109. /**
  1110. * Registers a callback to be triggered when the value has changed.
  1111. * Implemented as part of ControlValueAccessor.
  1112. * @param {?} fn Callback to be registered.
  1113. * @return {?}
  1114. */
  1115. MatSlider.prototype.registerOnChange = /**
  1116. * Registers a callback to be triggered when the value has changed.
  1117. * Implemented as part of ControlValueAccessor.
  1118. * @param {?} fn Callback to be registered.
  1119. * @return {?}
  1120. */
  1121. function (fn) {
  1122. this._controlValueAccessorChangeFn = fn;
  1123. };
  1124. /**
  1125. * Registers a callback to be triggered when the component is touched.
  1126. * Implemented as part of ControlValueAccessor.
  1127. * @param fn Callback to be registered.
  1128. */
  1129. /**
  1130. * Registers a callback to be triggered when the component is touched.
  1131. * Implemented as part of ControlValueAccessor.
  1132. * @param {?} fn Callback to be registered.
  1133. * @return {?}
  1134. */
  1135. MatSlider.prototype.registerOnTouched = /**
  1136. * Registers a callback to be triggered when the component is touched.
  1137. * Implemented as part of ControlValueAccessor.
  1138. * @param {?} fn Callback to be registered.
  1139. * @return {?}
  1140. */
  1141. function (fn) {
  1142. this.onTouched = fn;
  1143. };
  1144. /**
  1145. * Sets whether the component should be disabled.
  1146. * Implemented as part of ControlValueAccessor.
  1147. * @param isDisabled
  1148. */
  1149. /**
  1150. * Sets whether the component should be disabled.
  1151. * Implemented as part of ControlValueAccessor.
  1152. * @param {?} isDisabled
  1153. * @return {?}
  1154. */
  1155. MatSlider.prototype.setDisabledState = /**
  1156. * Sets whether the component should be disabled.
  1157. * Implemented as part of ControlValueAccessor.
  1158. * @param {?} isDisabled
  1159. * @return {?}
  1160. */
  1161. function (isDisabled) {
  1162. this.disabled = isDisabled;
  1163. };
  1164. MatSlider.decorators = [
  1165. { type: Component, args: [{selector: 'mat-slider',
  1166. exportAs: 'matSlider',
  1167. providers: [MAT_SLIDER_VALUE_ACCESSOR],
  1168. host: {
  1169. '(focus)': '_onFocus()',
  1170. '(blur)': '_onBlur()',
  1171. '(mousedown)': '_onMousedown($event)',
  1172. '(keydown)': '_onKeydown($event)',
  1173. '(keyup)': '_onKeyup()',
  1174. '(mouseenter)': '_onMouseenter()',
  1175. '(slide)': '_onSlide($event)',
  1176. '(slideend)': '_onSlideEnd()',
  1177. '(slidestart)': '_onSlideStart($event)',
  1178. // On Safari starting to slide temporarily triggers text selection mode which
  1179. // show the wrong cursor. We prevent it by stopping the `selectstart` event.
  1180. '(selectstart)': '$event.preventDefault()',
  1181. 'class': 'mat-slider',
  1182. 'role': 'slider',
  1183. '[tabIndex]': 'tabIndex',
  1184. '[attr.aria-disabled]': 'disabled',
  1185. '[attr.aria-valuemax]': 'max',
  1186. '[attr.aria-valuemin]': 'min',
  1187. '[attr.aria-valuenow]': 'value',
  1188. '[attr.aria-orientation]': 'vertical ? "vertical" : "horizontal"',
  1189. '[class.mat-slider-disabled]': 'disabled',
  1190. '[class.mat-slider-has-ticks]': 'tickInterval',
  1191. '[class.mat-slider-horizontal]': '!vertical',
  1192. '[class.mat-slider-axis-inverted]': '_invertAxis',
  1193. '[class.mat-slider-sliding]': '_isSliding',
  1194. '[class.mat-slider-thumb-label-showing]': 'thumbLabel',
  1195. '[class.mat-slider-vertical]': 'vertical',
  1196. '[class.mat-slider-min-value]': '_isMinValue',
  1197. '[class.mat-slider-hide-last-tick]': 'disabled || _isMinValue && _thumbGap && _invertAxis',
  1198. '[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
  1199. },
  1200. 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>",
  1201. styles: [".mat-slider{display:inline-block;position:relative;box-sizing:border-box;padding:8px;outline:0;vertical-align:middle}.mat-slider.mat-slider-sliding:not(.mat-slider-disabled),.mat-slider:not(.mat-slider-disabled):active{cursor:-webkit-grabbing;cursor:grabbing}.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)}.mat-slider.cdk-keyboard-focused .mat-slider-focus-ring,.mat-slider.cdk-program-focused .mat-slider-focus-ring{transform:scale(1);opacity:1}.mat-slider:not(.mat-slider-disabled):not(.mat-slider-sliding) .mat-slider-thumb,.mat-slider:not(.mat-slider-disabled):not(.mat-slider-sliding) .mat-slider-thumb-label{cursor:-webkit-grab;cursor:grab}.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)}@media (-ms-high-contrast:active){.mat-slider-thumb-label{outline:solid 1px}}.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{display:none}.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%}@media (-ms-high-contrast:active){.mat-slider-horizontal .mat-slider-ticks-container{height:0;outline:solid 2px;top:1px}}.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)}@media (-ms-high-contrast:active){.mat-slider-horizontal.cdk-focused .mat-slider-thumb-label,.mat-slider-horizontal.cdk-focused .mat-slider-thumb-label-text{transform:none}}.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%}@media (-ms-high-contrast:active){.mat-slider-vertical .mat-slider-ticks-container{width:0;outline:solid 2px;left:1px}}.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{-webkit-backface-visibility:hidden;backface-visibility:hidden}.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%}.mat-slider._mat-animation-noopable .mat-slider-focus-ring,.mat-slider._mat-animation-noopable .mat-slider-has-ticks .mat-slider-wrapper::after,.mat-slider._mat-animation-noopable .mat-slider-thumb,.mat-slider._mat-animation-noopable .mat-slider-thumb-container,.mat-slider._mat-animation-noopable .mat-slider-thumb-label,.mat-slider._mat-animation-noopable .mat-slider-thumb-label-text,.mat-slider._mat-animation-noopable .mat-slider-ticks,.mat-slider._mat-animation-noopable .mat-slider-track-background,.mat-slider._mat-animation-noopable .mat-slider-track-fill{transition:none}"],
  1202. inputs: ['disabled', 'color', 'tabIndex'],
  1203. encapsulation: ViewEncapsulation.None,
  1204. changeDetection: ChangeDetectionStrategy.OnPush,
  1205. },] },
  1206. ];
  1207. /** @nocollapse */
  1208. MatSlider.ctorParameters = function () { return [
  1209. { type: ElementRef },
  1210. { type: FocusMonitor },
  1211. { type: ChangeDetectorRef },
  1212. { type: Directionality, decorators: [{ type: Optional }] },
  1213. { type: String, decorators: [{ type: Attribute, args: ['tabindex',] }] },
  1214. { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
  1215. ]; };
  1216. MatSlider.propDecorators = {
  1217. invert: [{ type: Input }],
  1218. max: [{ type: Input }],
  1219. min: [{ type: Input }],
  1220. step: [{ type: Input }],
  1221. thumbLabel: [{ type: Input }],
  1222. tickInterval: [{ type: Input }],
  1223. value: [{ type: Input }],
  1224. displayWith: [{ type: Input }],
  1225. vertical: [{ type: Input }],
  1226. change: [{ type: Output }],
  1227. input: [{ type: Output }],
  1228. valueChange: [{ type: Output }],
  1229. _sliderWrapper: [{ type: ViewChild, args: ['sliderWrapper', { static: false },] }]
  1230. };
  1231. return MatSlider;
  1232. }(_MatSliderMixinBase));
  1233. /**
  1234. * @fileoverview added by tsickle
  1235. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1236. */
  1237. var MatSliderModule = /** @class */ (function () {
  1238. function MatSliderModule() {
  1239. }
  1240. MatSliderModule.decorators = [
  1241. { type: NgModule, args: [{
  1242. imports: [CommonModule, MatCommonModule],
  1243. exports: [MatSlider, MatCommonModule],
  1244. declarations: [MatSlider],
  1245. providers: [{ provide: HAMMER_GESTURE_CONFIG, useClass: GestureConfig }]
  1246. },] },
  1247. ];
  1248. return MatSliderModule;
  1249. }());
  1250. /**
  1251. * @fileoverview added by tsickle
  1252. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1253. */
  1254. /**
  1255. * @fileoverview added by tsickle
  1256. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1257. */
  1258. export { MatSliderModule, MAT_SLIDER_VALUE_ACCESSOR, MatSliderChange, MatSlider };
  1259. //# sourceMappingURL=slider.es5.js.map