ng5-slider.umd.js 113 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs/Subject'), require('rxjs/Subscription'), require('@angular/core'), require('rxjs/operators'), require('detect-passive-events'), require('@angular/forms'), require('@angular/common')) :
  3. typeof define === 'function' && define.amd ? define('ng5-slider', ['exports', 'rxjs/Subject', 'rxjs/Subscription', '@angular/core', 'rxjs/operators', 'detect-passive-events', '@angular/forms', '@angular/common'], factory) :
  4. (factory((global['ng5-slider'] = {}),global.Rx,global.Rx,global.ng.core,global.Rx.Observable.prototype,global.detectPassiveEvents,global.ng.forms,global.ng.common));
  5. }(this, (function (exports,Subject,Subscription,core,operators,detectPassiveEvents,forms,common) { 'use strict';
  6. detectPassiveEvents = detectPassiveEvents && detectPassiveEvents.hasOwnProperty('default') ? detectPassiveEvents['default'] : detectPassiveEvents;
  7. /*! *****************************************************************************
  8. Copyright (c) Microsoft Corporation. All rights reserved.
  9. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  10. this file except in compliance with the License. You may obtain a copy of the
  11. License at http://www.apache.org/licenses/LICENSE-2.0
  12. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  13. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  14. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  15. MERCHANTABLITY OR NON-INFRINGEMENT.
  16. See the Apache Version 2.0 License for specific language governing permissions
  17. and limitations under the License.
  18. ***************************************************************************** */
  19. /* global Reflect, Promise */
  20. var extendStatics = Object.setPrototypeOf ||
  21. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  22. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  23. function __extends(d, b) {
  24. extendStatics(d, b);
  25. function __() { this.constructor = d; }
  26. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  27. }
  28. function __values(o) {
  29. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  30. if (m) return m.call(o);
  31. return {
  32. next: function () {
  33. if (o && i >= o.length) o = void 0;
  34. return { value: o && o[i++], done: !o };
  35. }
  36. };
  37. }
  38. var PointerType = {
  39. Min: 0,
  40. Max: 1,
  41. };
  42. PointerType[PointerType.Min] = "Min";
  43. PointerType[PointerType.Max] = "Max";
  44. var LabelType = {
  45. Low: 0,
  46. High: 1,
  47. Floor: 2,
  48. Ceil: 3,
  49. TickValue: 4,
  50. };
  51. LabelType[LabelType.Low] = "Low";
  52. LabelType[LabelType.High] = "High";
  53. LabelType[LabelType.Floor] = "Floor";
  54. LabelType[LabelType.Ceil] = "Ceil";
  55. LabelType[LabelType.TickValue] = "TickValue";
  56. var Options = /** @class */ (function () {
  57. function Options() {
  58. this.floor = 0;
  59. this.ceil = null;
  60. this.step = 1;
  61. this.minRange = null;
  62. this.maxRange = null;
  63. this.pushRange = false;
  64. this.minLimit = null;
  65. this.maxLimit = null;
  66. this.translate = null;
  67. this.combineLabels = null;
  68. this.getLegend = null;
  69. this.stepsArray = null;
  70. this.bindIndexForStepsArray = false;
  71. this.draggableRange = false;
  72. this.draggableRangeOnly = false;
  73. this.showSelectionBar = false;
  74. this.showSelectionBarEnd = false;
  75. this.showSelectionBarFromValue = null;
  76. this.showOuterSelectionBars = false;
  77. this.hidePointerLabels = false;
  78. this.hideLimitLabels = false;
  79. this.autoHideLimitLabels = true;
  80. this.readOnly = false;
  81. this.disabled = false;
  82. this.mouseEventsInterval = 50;
  83. this.touchEventsInterval = 50;
  84. this.inputEventsInterval = 100;
  85. this.outputEventsInterval = 100;
  86. this.showTicks = false;
  87. this.showTicksValues = false;
  88. this.tickStep = null;
  89. this.tickValueStep = 1;
  90. this.ticksArray = null;
  91. this.ticksTooltip = null;
  92. this.ticksValuesTooltip = null;
  93. this.vertical = false;
  94. this.getSelectionBarColor = null;
  95. this.getTickColor = null;
  96. this.getPointerColor = null;
  97. this.keyboardSupport = true;
  98. this.scale = 1;
  99. this.enforceStep = true;
  100. this.enforceRange = true;
  101. this.noSwitching = false;
  102. this.onlyBindHandles = false;
  103. this.rightToLeft = false;
  104. this.reversedControls = false;
  105. this.boundPointerLabels = true;
  106. this.logScale = false;
  107. this.customValueToPosition = null;
  108. this.customPositionToValue = null;
  109. this.precisionLimit = 12;
  110. this.selectionBarGradient = null;
  111. this.ariaLabel = null;
  112. this.ariaLabelledBy = null;
  113. this.ariaLabelHigh = null;
  114. this.ariaLabelledByHigh = null;
  115. this.handleDimension = null;
  116. this.barDimension = null;
  117. this.animate = true;
  118. }
  119. return Options;
  120. }());
  121. var ChangeContext = /** @class */ (function () {
  122. function ChangeContext() {
  123. }
  124. return ChangeContext;
  125. }());
  126. var ValueHelper = /** @class */ (function () {
  127. function ValueHelper() {
  128. }
  129. ValueHelper.isNullOrUndefined = function (value) {
  130. return value === undefined || value === null;
  131. };
  132. ValueHelper.linearValueToPosition = function (val, minVal, maxVal) {
  133. var range = maxVal - minVal;
  134. return (val - minVal) / range;
  135. };
  136. ValueHelper.logValueToPosition = function (val, minVal, maxVal) {
  137. val = Math.log(val);
  138. minVal = Math.log(minVal);
  139. maxVal = Math.log(maxVal);
  140. var range = maxVal - minVal;
  141. return (val - minVal) / range;
  142. };
  143. ValueHelper.linearPositionToValue = function (percent, minVal, maxVal) {
  144. return percent * (maxVal - minVal) + minVal;
  145. };
  146. ValueHelper.logPositionToValue = function (percent, minVal, maxVal) {
  147. minVal = Math.log(minVal);
  148. maxVal = Math.log(maxVal);
  149. var value = percent * (maxVal - minVal) + minVal;
  150. return Math.exp(value);
  151. };
  152. ValueHelper.findStepIndex = function (modelValue, stepsArray) {
  153. var differences = stepsArray.map(function (step) { return Math.abs(modelValue - step.value); });
  154. var minDifferenceIndex = 0;
  155. for (var index = 0; index < stepsArray.length; index++) {
  156. if (differences[index] !== differences[minDifferenceIndex] && differences[index] < differences[minDifferenceIndex]) {
  157. minDifferenceIndex = index;
  158. }
  159. }
  160. return minDifferenceIndex;
  161. };
  162. return ValueHelper;
  163. }());
  164. var CompatibilityHelper = /** @class */ (function () {
  165. function CompatibilityHelper() {
  166. }
  167. CompatibilityHelper.isTouchEvent = function (event) {
  168. if (((window)).TouchEvent !== undefined) {
  169. return event instanceof TouchEvent;
  170. }
  171. return event.touches !== undefined;
  172. };
  173. CompatibilityHelper.isResizeObserverAvailable = function () {
  174. return ((window)).ResizeObserver !== undefined;
  175. };
  176. return CompatibilityHelper;
  177. }());
  178. var MathHelper = /** @class */ (function () {
  179. function MathHelper() {
  180. }
  181. MathHelper.roundToPrecisionLimit = function (value, precisionLimit) {
  182. return +(value.toPrecision(precisionLimit));
  183. };
  184. MathHelper.clampToRange = function (value, floor, ceil) {
  185. return Math.min(Math.max(value, floor), ceil);
  186. };
  187. return MathHelper;
  188. }());
  189. var EventListener = /** @class */ (function () {
  190. function EventListener() {
  191. this.eventName = null;
  192. this.events = null;
  193. this.eventsSubscription = null;
  194. this.teardownCallback = null;
  195. }
  196. return EventListener;
  197. }());
  198. var EventListenerHelper = /** @class */ (function () {
  199. function EventListenerHelper(renderer) {
  200. this.renderer = renderer;
  201. }
  202. EventListenerHelper.prototype.attachPassiveEventListener = function (nativeElement, eventName, callback, throttleInterval) {
  203. if (detectPassiveEvents.hasSupport !== true) {
  204. return this.attachEventListener(nativeElement, eventName, callback, throttleInterval);
  205. }
  206. var listener = new EventListener();
  207. listener.eventName = eventName;
  208. listener.events = new Subject.Subject();
  209. var observerCallback = function (event) {
  210. listener.events.next(event);
  211. };
  212. nativeElement.addEventListener(eventName, observerCallback, { passive: true, capture: false });
  213. listener.teardownCallback = function () {
  214. nativeElement.removeEventListener(eventName, observerCallback, { passive: true, capture: false });
  215. };
  216. listener.eventsSubscription = listener.events
  217. .pipe((!ValueHelper.isNullOrUndefined(throttleInterval))
  218. ? operators.throttleTime(throttleInterval, undefined, { leading: true, trailing: true })
  219. : operators.tap(function () { }))
  220. .subscribe(function (event) {
  221. callback(event);
  222. });
  223. return listener;
  224. };
  225. EventListenerHelper.prototype.detachEventListener = function (eventListener) {
  226. if (!ValueHelper.isNullOrUndefined(eventListener.eventsSubscription)) {
  227. eventListener.eventsSubscription.unsubscribe();
  228. eventListener.eventsSubscription = null;
  229. }
  230. if (!ValueHelper.isNullOrUndefined(eventListener.events)) {
  231. eventListener.events.complete();
  232. eventListener.events = null;
  233. }
  234. if (!ValueHelper.isNullOrUndefined(eventListener.teardownCallback)) {
  235. eventListener.teardownCallback();
  236. eventListener.teardownCallback = null;
  237. }
  238. };
  239. EventListenerHelper.prototype.attachEventListener = function (nativeElement, eventName, callback, throttleInterval) {
  240. var listener = new EventListener();
  241. listener.eventName = eventName;
  242. listener.events = new Subject.Subject();
  243. var observerCallback = function (event) {
  244. listener.events.next(event);
  245. };
  246. listener.teardownCallback = this.renderer.listen(nativeElement, eventName, observerCallback);
  247. listener.eventsSubscription = listener.events
  248. .pipe((!ValueHelper.isNullOrUndefined(throttleInterval))
  249. ? operators.throttleTime(throttleInterval, undefined, { leading: true, trailing: true })
  250. : operators.tap(function () { }))
  251. .subscribe(function (event) { callback(event); });
  252. return listener;
  253. };
  254. return EventListenerHelper;
  255. }());
  256. var SliderElementDirective = /** @class */ (function () {
  257. function SliderElementDirective(elemRef, renderer) {
  258. this.elemRef = elemRef;
  259. this.renderer = renderer;
  260. this._position = 0;
  261. this._dimension = 0;
  262. this._alwaysHide = false;
  263. this._vertical = false;
  264. this._scale = 1;
  265. this.opacity = 1;
  266. this.visibility = 'visible';
  267. this.left = '';
  268. this.bottom = '';
  269. this.height = '';
  270. this.width = '';
  271. this.eventListeners = [];
  272. this.eventListenerHelper = new EventListenerHelper(this.renderer);
  273. }
  274. Object.defineProperty(SliderElementDirective.prototype, "position", {
  275. get: function () {
  276. return this._position;
  277. },
  278. enumerable: true,
  279. configurable: true
  280. });
  281. Object.defineProperty(SliderElementDirective.prototype, "dimension", {
  282. get: function () {
  283. return this._dimension;
  284. },
  285. enumerable: true,
  286. configurable: true
  287. });
  288. Object.defineProperty(SliderElementDirective.prototype, "alwaysHide", {
  289. get: function () {
  290. return this._alwaysHide;
  291. },
  292. enumerable: true,
  293. configurable: true
  294. });
  295. Object.defineProperty(SliderElementDirective.prototype, "vertical", {
  296. get: function () {
  297. return this._vertical;
  298. },
  299. enumerable: true,
  300. configurable: true
  301. });
  302. Object.defineProperty(SliderElementDirective.prototype, "scale", {
  303. get: function () {
  304. return this._scale;
  305. },
  306. enumerable: true,
  307. configurable: true
  308. });
  309. SliderElementDirective.prototype.setAlwaysHide = function (hide) {
  310. this._alwaysHide = hide;
  311. if (hide) {
  312. this.visibility = 'hidden';
  313. }
  314. else {
  315. this.visibility = 'visible';
  316. }
  317. };
  318. SliderElementDirective.prototype.hide = function () {
  319. this.opacity = 0;
  320. };
  321. SliderElementDirective.prototype.show = function () {
  322. if (this.alwaysHide) {
  323. return;
  324. }
  325. this.opacity = 1;
  326. };
  327. SliderElementDirective.prototype.isVisible = function () {
  328. if (this.alwaysHide) {
  329. return false;
  330. }
  331. return this.opacity !== 0;
  332. };
  333. SliderElementDirective.prototype.setVertical = function (vertical) {
  334. this._vertical = vertical;
  335. if (this._vertical) {
  336. this.left = '';
  337. this.width = '';
  338. }
  339. else {
  340. this.bottom = '';
  341. this.height = '';
  342. }
  343. };
  344. SliderElementDirective.prototype.setScale = function (scale) {
  345. this._scale = scale;
  346. };
  347. SliderElementDirective.prototype.setPosition = function (pos) {
  348. this._position = pos;
  349. if (this._vertical) {
  350. this.bottom = Math.round(pos) + 'px';
  351. }
  352. else {
  353. this.left = Math.round(pos) + 'px';
  354. }
  355. };
  356. SliderElementDirective.prototype.calculateDimension = function () {
  357. var val = this.getBoundingClientRect();
  358. if (this.vertical) {
  359. this._dimension = (val.bottom - val.top) * this.scale;
  360. }
  361. else {
  362. this._dimension = (val.right - val.left) * this.scale;
  363. }
  364. };
  365. SliderElementDirective.prototype.setDimension = function (dim) {
  366. this._dimension = dim;
  367. if (this._vertical) {
  368. this.height = Math.round(dim) + 'px';
  369. }
  370. else {
  371. this.width = Math.round(dim) + 'px';
  372. }
  373. };
  374. SliderElementDirective.prototype.getBoundingClientRect = function () {
  375. return this.elemRef.nativeElement.getBoundingClientRect();
  376. };
  377. SliderElementDirective.prototype.on = function (eventName, callback, debounceInterval) {
  378. var listener = this.eventListenerHelper.attachEventListener(this.elemRef.nativeElement, eventName, callback, debounceInterval);
  379. this.eventListeners.push(listener);
  380. };
  381. SliderElementDirective.prototype.onPassive = function (eventName, callback, debounceInterval) {
  382. var listener = this.eventListenerHelper.attachPassiveEventListener(this.elemRef.nativeElement, eventName, callback, debounceInterval);
  383. this.eventListeners.push(listener);
  384. };
  385. SliderElementDirective.prototype.off = function (eventName) {
  386. var listenersToKeep;
  387. var listenersToRemove;
  388. if (!ValueHelper.isNullOrUndefined(eventName)) {
  389. listenersToKeep = this.eventListeners.filter(function (event) { return event.eventName !== eventName; });
  390. listenersToRemove = this.eventListeners.filter(function (event) { return event.eventName === eventName; });
  391. }
  392. else {
  393. listenersToKeep = [];
  394. listenersToRemove = this.eventListeners;
  395. }
  396. try {
  397. for (var listenersToRemove_1 = __values(listenersToRemove), listenersToRemove_1_1 = listenersToRemove_1.next(); !listenersToRemove_1_1.done; listenersToRemove_1_1 = listenersToRemove_1.next()) {
  398. var listener = listenersToRemove_1_1.value;
  399. this.eventListenerHelper.detachEventListener(listener);
  400. }
  401. }
  402. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  403. finally {
  404. try {
  405. if (listenersToRemove_1_1 && !listenersToRemove_1_1.done && (_a = listenersToRemove_1.return)) _a.call(listenersToRemove_1);
  406. }
  407. finally { if (e_1) throw e_1.error; }
  408. }
  409. this.eventListeners = listenersToKeep;
  410. var e_1, _a;
  411. };
  412. return SliderElementDirective;
  413. }());
  414. SliderElementDirective.decorators = [
  415. { type: core.Directive, args: [{
  416. selector: '[ng5SliderElement]'
  417. },] },
  418. ];
  419. SliderElementDirective.ctorParameters = function () { return [
  420. { type: core.ElementRef, },
  421. { type: core.Renderer2, },
  422. ]; };
  423. SliderElementDirective.propDecorators = {
  424. "opacity": [{ type: core.HostBinding, args: ['style.opacity',] },],
  425. "visibility": [{ type: core.HostBinding, args: ['style.visibility',] },],
  426. "left": [{ type: core.HostBinding, args: ['style.left',] },],
  427. "bottom": [{ type: core.HostBinding, args: ['style.bottom',] },],
  428. "height": [{ type: core.HostBinding, args: ['style.height',] },],
  429. "width": [{ type: core.HostBinding, args: ['style.width',] },],
  430. };
  431. var SliderHandleDirective = /** @class */ (function (_super) {
  432. __extends(SliderHandleDirective, _super);
  433. function SliderHandleDirective(elemRef, renderer) {
  434. var _this = _super.call(this, elemRef, renderer) || this;
  435. _this.active = false;
  436. _this.role = '';
  437. _this.tabindex = '';
  438. _this.ariaOrientation = '';
  439. _this.ariaLabel = '';
  440. _this.ariaLabelledBy = '';
  441. _this.ariaValueNow = '';
  442. _this.ariaValueText = '';
  443. _this.ariaValueMin = '';
  444. _this.ariaValueMax = '';
  445. return _this;
  446. }
  447. SliderHandleDirective.prototype.focus = function () {
  448. this.elemRef.nativeElement.focus();
  449. };
  450. return SliderHandleDirective;
  451. }(SliderElementDirective));
  452. SliderHandleDirective.decorators = [
  453. { type: core.Directive, args: [{
  454. selector: '[ng5SliderHandle]'
  455. },] },
  456. ];
  457. SliderHandleDirective.ctorParameters = function () { return [
  458. { type: core.ElementRef, },
  459. { type: core.Renderer2, },
  460. ]; };
  461. SliderHandleDirective.propDecorators = {
  462. "active": [{ type: core.HostBinding, args: ['class.ng5-slider-active',] },],
  463. "role": [{ type: core.HostBinding, args: ['attr.role',] },],
  464. "tabindex": [{ type: core.HostBinding, args: ['attr.tabindex',] },],
  465. "ariaOrientation": [{ type: core.HostBinding, args: ['attr.aria-orientation',] },],
  466. "ariaLabel": [{ type: core.HostBinding, args: ['attr.aria-label',] },],
  467. "ariaLabelledBy": [{ type: core.HostBinding, args: ['attr.aria-labelledby',] },],
  468. "ariaValueNow": [{ type: core.HostBinding, args: ['attr.aria-valuenow',] },],
  469. "ariaValueText": [{ type: core.HostBinding, args: ['attr.aria-valuetext',] },],
  470. "ariaValueMin": [{ type: core.HostBinding, args: ['attr.aria-valuemin',] },],
  471. "ariaValueMax": [{ type: core.HostBinding, args: ['attr.aria-valuemax',] },],
  472. };
  473. var SliderLabelDirective = /** @class */ (function (_super) {
  474. __extends(SliderLabelDirective, _super);
  475. function SliderLabelDirective(elemRef, renderer) {
  476. var _this = _super.call(this, elemRef, renderer) || this;
  477. _this._value = null;
  478. return _this;
  479. }
  480. Object.defineProperty(SliderLabelDirective.prototype, "value", {
  481. get: function () {
  482. return this._value;
  483. },
  484. enumerable: true,
  485. configurable: true
  486. });
  487. SliderLabelDirective.prototype.setValue = function (value) {
  488. var recalculateDimension = false;
  489. if (!this.alwaysHide &&
  490. (ValueHelper.isNullOrUndefined(this.value) ||
  491. this.value.length !== value.length ||
  492. (this.value.length > 0 && this.dimension === 0))) {
  493. recalculateDimension = true;
  494. }
  495. this._value = value;
  496. this.elemRef.nativeElement.innerHTML = value;
  497. if (recalculateDimension) {
  498. this.calculateDimension();
  499. }
  500. };
  501. return SliderLabelDirective;
  502. }(SliderElementDirective));
  503. SliderLabelDirective.decorators = [
  504. { type: core.Directive, args: [{
  505. selector: '[ng5SliderLabel]'
  506. },] },
  507. ];
  508. SliderLabelDirective.ctorParameters = function () { return [
  509. { type: core.ElementRef, },
  510. { type: core.Renderer2, },
  511. ]; };
  512. var Tick = /** @class */ (function () {
  513. function Tick() {
  514. this.selected = false;
  515. this.style = {};
  516. this.tooltip = null;
  517. this.tooltipPlacement = null;
  518. this.value = null;
  519. this.valueTooltip = null;
  520. this.valueTooltipPlacement = null;
  521. this.legend = null;
  522. }
  523. return Tick;
  524. }());
  525. var Dragging = /** @class */ (function () {
  526. function Dragging() {
  527. this.active = false;
  528. this.value = 0;
  529. this.difference = 0;
  530. this.position = 0;
  531. this.lowLimit = 0;
  532. this.highLimit = 0;
  533. }
  534. return Dragging;
  535. }());
  536. var ModelValues = /** @class */ (function () {
  537. function ModelValues() {
  538. }
  539. ModelValues.compare = function (x, y) {
  540. if (ValueHelper.isNullOrUndefined(x) && ValueHelper.isNullOrUndefined(y)) {
  541. return false;
  542. }
  543. if (ValueHelper.isNullOrUndefined(x) !== ValueHelper.isNullOrUndefined(y)) {
  544. return false;
  545. }
  546. return x.value === y.value && x.highValue === y.highValue;
  547. };
  548. return ModelValues;
  549. }());
  550. var ModelChange = /** @class */ (function (_super) {
  551. __extends(ModelChange, _super);
  552. function ModelChange() {
  553. return _super !== null && _super.apply(this, arguments) || this;
  554. }
  555. ModelChange.compare = function (x, y) {
  556. if (ValueHelper.isNullOrUndefined(x) && ValueHelper.isNullOrUndefined(y)) {
  557. return false;
  558. }
  559. if (ValueHelper.isNullOrUndefined(x) !== ValueHelper.isNullOrUndefined(y)) {
  560. return false;
  561. }
  562. return x.value === y.value &&
  563. x.highValue === y.highValue &&
  564. x.forceChange === y.forceChange;
  565. };
  566. return ModelChange;
  567. }(ModelValues));
  568. var NG5_SLIDER_CONTROL_VALUE_ACCESSOR = {
  569. provide: forms.NG_VALUE_ACCESSOR,
  570. useExisting: core.forwardRef(function () { return SliderComponent; }),
  571. multi: true,
  572. };
  573. var SliderComponent = /** @class */ (function () {
  574. function SliderComponent(renderer, elementRef, changeDetectionRef, zone) {
  575. this.renderer = renderer;
  576. this.elementRef = elementRef;
  577. this.changeDetectionRef = changeDetectionRef;
  578. this.zone = zone;
  579. this.value = null;
  580. this.valueChange = new core.EventEmitter();
  581. this.highValue = null;
  582. this.highValueChange = new core.EventEmitter();
  583. this.options = new Options();
  584. this.userChangeStart = new core.EventEmitter();
  585. this.userChange = new core.EventEmitter();
  586. this.userChangeEnd = new core.EventEmitter();
  587. this.initHasRun = false;
  588. this.inputModelChangeSubject = new Subject.Subject();
  589. this.inputModelChangeSubscription = null;
  590. this.outputModelChangeSubject = new Subject.Subject();
  591. this.outputModelChangeSubscription = null;
  592. this.viewLowValue = null;
  593. this.viewHighValue = null;
  594. this.viewOptions = new Options();
  595. this.handleHalfDimension = 0;
  596. this.maxHandlePosition = 0;
  597. this.currentTrackingPointer = null;
  598. this.currentFocusPointer = null;
  599. this.firstKeyDown = false;
  600. this.touchId = null;
  601. this.dragging = new Dragging();
  602. this.sliderElementVerticalClass = false;
  603. this.sliderElementAnimateClass = false;
  604. this.sliderElementDisabledAttr = null;
  605. this.barStyle = {};
  606. this.minPointerStyle = {};
  607. this.maxPointerStyle = {};
  608. this.fullBarTransparentClass = false;
  609. this.selectionBarDraggableClass = false;
  610. this.ticksUnderValuesClass = false;
  611. this.intermediateTicks = false;
  612. this.ticks = [];
  613. this.eventListenerHelper = null;
  614. this.onMoveEventListener = null;
  615. this.onEndEventListener = null;
  616. this.resizeObserver = null;
  617. this.onTouchedCallback = null;
  618. this.onChangeCallback = null;
  619. this.eventListenerHelper = new EventListenerHelper(this.renderer);
  620. }
  621. Object.defineProperty(SliderComponent.prototype, "manualRefresh", {
  622. set: function (manualRefresh) {
  623. var _this = this;
  624. this.unsubscribeManualRefresh();
  625. this.manualRefreshSubscription = manualRefresh.subscribe(function () {
  626. setTimeout(function () { return _this.calculateViewDimensionsAndDetectChanges(); });
  627. });
  628. },
  629. enumerable: true,
  630. configurable: true
  631. });
  632. Object.defineProperty(SliderComponent.prototype, "triggerFocus", {
  633. set: function (triggerFocus) {
  634. var _this = this;
  635. this.unsubscribeTriggerFocus();
  636. this.triggerFocusSubscription = triggerFocus.subscribe(function (pointerType) {
  637. _this.focusPointer(pointerType);
  638. });
  639. },
  640. enumerable: true,
  641. configurable: true
  642. });
  643. Object.defineProperty(SliderComponent.prototype, "range", {
  644. get: function () {
  645. return !ValueHelper.isNullOrUndefined(this.value) && !ValueHelper.isNullOrUndefined(this.highValue);
  646. },
  647. enumerable: true,
  648. configurable: true
  649. });
  650. Object.defineProperty(SliderComponent.prototype, "showTicks", {
  651. get: function () {
  652. return this.viewOptions.showTicks;
  653. },
  654. enumerable: true,
  655. configurable: true
  656. });
  657. SliderComponent.prototype.ngOnInit = function () {
  658. this.viewOptions = new Options();
  659. Object.assign(this.viewOptions, this.options);
  660. this.updateDisabledState();
  661. this.updateVerticalState();
  662. };
  663. SliderComponent.prototype.ngAfterViewInit = function () {
  664. this.applyOptions();
  665. this.subscribeInputModelChangeSubject(this.viewOptions.inputEventsInterval);
  666. this.subscribeOutputModelChangeSubject(this.viewOptions.outputEventsInterval);
  667. this.renormaliseModelValues();
  668. this.viewLowValue = this.modelValueToViewValue(this.value);
  669. if (this.range) {
  670. this.viewHighValue = this.modelValueToViewValue(this.highValue);
  671. }
  672. else {
  673. this.viewHighValue = null;
  674. }
  675. this.updateVerticalState();
  676. this.manageElementsStyle();
  677. this.updateDisabledState();
  678. this.calculateViewDimensions();
  679. this.addAccessibility();
  680. this.updateCeilLabel();
  681. this.updateFloorLabel();
  682. this.initHandles();
  683. this.manageEventsBindings();
  684. this.subscribeResizeObserver();
  685. this.initHasRun = true;
  686. this.changeDetectionRef.detectChanges();
  687. };
  688. SliderComponent.prototype.ngOnChanges = function (changes) {
  689. if (!ValueHelper.isNullOrUndefined(changes["options"])) {
  690. this.onChangeOptions();
  691. }
  692. if (!ValueHelper.isNullOrUndefined(changes["value"]) ||
  693. !ValueHelper.isNullOrUndefined(changes["highValue"])) {
  694. this.inputModelChangeSubject.next({
  695. value: this.value,
  696. highValue: this.highValue,
  697. forceChange: false,
  698. internalChange: false
  699. });
  700. }
  701. };
  702. SliderComponent.prototype.ngOnDestroy = function () {
  703. this.unbindEvents();
  704. this.unsubscribeResizeObserver();
  705. this.unsubscribeInputModelChangeSubject();
  706. this.unsubscribeOutputModelChangeSubject();
  707. this.unsubscribeManualRefresh();
  708. this.unsubscribeTriggerFocus();
  709. };
  710. SliderComponent.prototype.writeValue = function (obj) {
  711. if (obj instanceof Array) {
  712. this.value = obj[0];
  713. this.highValue = obj[1];
  714. }
  715. else {
  716. this.value = obj;
  717. }
  718. this.inputModelChangeSubject.next({
  719. value: this.value,
  720. highValue: this.highValue,
  721. forceChange: false,
  722. internalChange: false
  723. });
  724. };
  725. SliderComponent.prototype.registerOnChange = function (onChangeCallback) {
  726. this.onChangeCallback = onChangeCallback;
  727. };
  728. SliderComponent.prototype.registerOnTouched = function (onTouchedCallback) {
  729. this.onTouchedCallback = onTouchedCallback;
  730. };
  731. SliderComponent.prototype.setDisabledState = function (isDisabled) {
  732. this.viewOptions.disabled = isDisabled;
  733. this.updateDisabledState();
  734. };
  735. SliderComponent.prototype.onResize = function (event) {
  736. this.calculateViewDimensionsAndDetectChanges();
  737. };
  738. SliderComponent.prototype.subscribeInputModelChangeSubject = function (interval) {
  739. var _this = this;
  740. this.inputModelChangeSubscription = this.inputModelChangeSubject
  741. .pipe(operators.distinctUntilChanged(ModelChange.compare), operators.filter(function (modelChange) { return !modelChange.forceChange && !modelChange.internalChange; }), (!ValueHelper.isNullOrUndefined(interval))
  742. ? operators.throttleTime(interval, undefined, { leading: true, trailing: true })
  743. : operators.tap(function () { }))
  744. .subscribe(function (modelChange) { return _this.applyInputModelChange(modelChange); });
  745. };
  746. SliderComponent.prototype.subscribeOutputModelChangeSubject = function (interval) {
  747. var _this = this;
  748. this.outputModelChangeSubscription = this.outputModelChangeSubject
  749. .pipe(operators.distinctUntilChanged(ModelChange.compare), (!ValueHelper.isNullOrUndefined(interval))
  750. ? operators.throttleTime(interval, undefined, { leading: true, trailing: true })
  751. : operators.tap(function () { }))
  752. .subscribe(function (modelChange) { return _this.publishOutputModelChange(modelChange); });
  753. };
  754. SliderComponent.prototype.subscribeResizeObserver = function () {
  755. var _this = this;
  756. if (CompatibilityHelper.isResizeObserverAvailable()) {
  757. this.resizeObserver = new ResizeObserver(function () { return _this.calculateViewDimensionsAndDetectChanges(); });
  758. this.resizeObserver.observe(this.elementRef.nativeElement);
  759. }
  760. };
  761. SliderComponent.prototype.unsubscribeResizeObserver = function () {
  762. if (CompatibilityHelper.isResizeObserverAvailable() && this.resizeObserver !== null) {
  763. this.resizeObserver.disconnect();
  764. this.resizeObserver = null;
  765. }
  766. };
  767. SliderComponent.prototype.unsubscribeOnMove = function () {
  768. if (!ValueHelper.isNullOrUndefined(this.onMoveEventListener)) {
  769. this.eventListenerHelper.detachEventListener(this.onMoveEventListener);
  770. this.onMoveEventListener = null;
  771. }
  772. };
  773. SliderComponent.prototype.unsubscribeOnEnd = function () {
  774. if (!ValueHelper.isNullOrUndefined(this.onEndEventListener)) {
  775. this.eventListenerHelper.detachEventListener(this.onEndEventListener);
  776. this.onEndEventListener = null;
  777. }
  778. };
  779. SliderComponent.prototype.unsubscribeInputModelChangeSubject = function () {
  780. if (!ValueHelper.isNullOrUndefined(this.inputModelChangeSubscription)) {
  781. this.inputModelChangeSubscription.unsubscribe();
  782. this.inputModelChangeSubscription = null;
  783. }
  784. };
  785. SliderComponent.prototype.unsubscribeOutputModelChangeSubject = function () {
  786. if (!ValueHelper.isNullOrUndefined(this.outputModelChangeSubscription)) {
  787. this.outputModelChangeSubscription.unsubscribe();
  788. this.outputModelChangeSubscription = null;
  789. }
  790. };
  791. SliderComponent.prototype.unsubscribeManualRefresh = function () {
  792. if (!ValueHelper.isNullOrUndefined(this.manualRefreshSubscription)) {
  793. this.manualRefreshSubscription.unsubscribe();
  794. this.manualRefreshSubscription = null;
  795. }
  796. };
  797. SliderComponent.prototype.unsubscribeTriggerFocus = function () {
  798. if (!ValueHelper.isNullOrUndefined(this.triggerFocusSubscription)) {
  799. this.triggerFocusSubscription.unsubscribe();
  800. this.triggerFocusSubscription = null;
  801. }
  802. };
  803. SliderComponent.prototype.getPointerElement = function (pointerType) {
  804. if (pointerType === PointerType.Min) {
  805. return this.minHandleElement;
  806. }
  807. else if (pointerType === PointerType.Max) {
  808. return this.maxHandleElement;
  809. }
  810. return null;
  811. };
  812. SliderComponent.prototype.getCurrentTrackingValue = function () {
  813. if (this.currentTrackingPointer === PointerType.Min) {
  814. return this.viewLowValue;
  815. }
  816. else if (this.currentTrackingPointer === PointerType.Max) {
  817. return this.viewHighValue;
  818. }
  819. return null;
  820. };
  821. SliderComponent.prototype.modelValueToViewValue = function (modelValue) {
  822. if (ValueHelper.isNullOrUndefined(modelValue)) {
  823. return NaN;
  824. }
  825. if (!ValueHelper.isNullOrUndefined(this.viewOptions.stepsArray) && !this.viewOptions.bindIndexForStepsArray) {
  826. return ValueHelper.findStepIndex(+modelValue, this.viewOptions.stepsArray);
  827. }
  828. return +modelValue;
  829. };
  830. SliderComponent.prototype.viewValueToModelValue = function (viewValue) {
  831. if (!ValueHelper.isNullOrUndefined(this.viewOptions.stepsArray) && !this.viewOptions.bindIndexForStepsArray) {
  832. return this.getStepValue(viewValue);
  833. }
  834. return viewValue;
  835. };
  836. SliderComponent.prototype.getStepValue = function (sliderValue) {
  837. var step = this.viewOptions.stepsArray[sliderValue];
  838. return (!ValueHelper.isNullOrUndefined(step)) ? step.value : NaN;
  839. };
  840. SliderComponent.prototype.applyViewChange = function () {
  841. this.value = this.viewValueToModelValue(this.viewLowValue);
  842. if (this.range) {
  843. this.highValue = this.viewValueToModelValue(this.viewHighValue);
  844. }
  845. this.outputModelChangeSubject.next({
  846. value: this.value,
  847. highValue: this.highValue,
  848. userEventInitiated: true,
  849. forceChange: false
  850. });
  851. this.inputModelChangeSubject.next({
  852. value: this.value,
  853. highValue: this.highValue,
  854. forceChange: false,
  855. internalChange: true
  856. });
  857. };
  858. SliderComponent.prototype.applyInputModelChange = function (modelChange) {
  859. var normalisedModelChange = this.normaliseModelValues(modelChange);
  860. var normalisationChange = !ModelValues.compare(modelChange, normalisedModelChange);
  861. if (normalisationChange) {
  862. this.value = normalisedModelChange.value;
  863. this.highValue = normalisedModelChange.highValue;
  864. }
  865. this.viewLowValue = this.modelValueToViewValue(normalisedModelChange.value);
  866. if (this.range) {
  867. this.viewHighValue = this.modelValueToViewValue(normalisedModelChange.highValue);
  868. }
  869. else {
  870. this.viewHighValue = null;
  871. }
  872. this.updateLowHandle(this.valueToPosition(this.viewLowValue));
  873. if (this.range) {
  874. this.updateHighHandle(this.valueToPosition(this.viewHighValue));
  875. }
  876. this.updateSelectionBar();
  877. this.updateTicksScale();
  878. this.updateAriaAttributes();
  879. if (this.range) {
  880. this.updateCombinedLabel();
  881. }
  882. this.outputModelChangeSubject.next({
  883. value: normalisedModelChange.value,
  884. highValue: normalisedModelChange.highValue,
  885. forceChange: normalisationChange,
  886. userEventInitiated: false
  887. });
  888. };
  889. SliderComponent.prototype.publishOutputModelChange = function (modelChange) {
  890. var _this = this;
  891. var emitOutputs = function () {
  892. _this.valueChange.emit(modelChange.value);
  893. if (_this.range) {
  894. _this.highValueChange.emit(modelChange.highValue);
  895. }
  896. if (!ValueHelper.isNullOrUndefined(_this.onChangeCallback)) {
  897. if (_this.range) {
  898. _this.onChangeCallback([modelChange.value, modelChange.highValue]);
  899. }
  900. else {
  901. _this.onChangeCallback(modelChange.value);
  902. }
  903. }
  904. if (!ValueHelper.isNullOrUndefined(_this.onTouchedCallback)) {
  905. if (_this.range) {
  906. _this.onTouchedCallback([modelChange.value, modelChange.highValue]);
  907. }
  908. else {
  909. _this.onTouchedCallback(modelChange.value);
  910. }
  911. }
  912. };
  913. if (modelChange.userEventInitiated) {
  914. emitOutputs();
  915. this.userChange.emit(this.getChangeContext());
  916. }
  917. else {
  918. setTimeout(function () { emitOutputs(); });
  919. }
  920. };
  921. SliderComponent.prototype.normaliseModelValues = function (input) {
  922. var normalisedInput = new ModelValues();
  923. normalisedInput.value = input.value;
  924. normalisedInput.highValue = input.highValue;
  925. if (this.viewOptions.enforceStep) {
  926. normalisedInput.value = this.roundStep(normalisedInput.value);
  927. if (this.range) {
  928. normalisedInput.highValue = this.roundStep(normalisedInput.highValue);
  929. }
  930. }
  931. if (!ValueHelper.isNullOrUndefined(this.viewOptions.stepsArray) || !this.viewOptions.enforceRange) {
  932. return normalisedInput;
  933. }
  934. normalisedInput.value = MathHelper.clampToRange(normalisedInput.value, this.viewOptions.floor, this.viewOptions.ceil);
  935. if (this.range) {
  936. normalisedInput.highValue = MathHelper.clampToRange(normalisedInput.highValue, this.viewOptions.floor, this.viewOptions.ceil);
  937. }
  938. if (this.range && input.value > input.highValue) {
  939. if (this.viewOptions.noSwitching) {
  940. normalisedInput.value = normalisedInput.highValue;
  941. }
  942. else {
  943. var tempValue = input.value;
  944. normalisedInput.value = input.highValue;
  945. normalisedInput.highValue = tempValue;
  946. }
  947. }
  948. return normalisedInput;
  949. };
  950. SliderComponent.prototype.renormaliseModelValues = function () {
  951. var previousModelValues = {
  952. value: this.value,
  953. highValue: this.highValue
  954. };
  955. var normalisedModelValues = this.normaliseModelValues(previousModelValues);
  956. if (!ModelValues.compare(normalisedModelValues, previousModelValues)) {
  957. this.value = normalisedModelValues.value;
  958. this.highValue = normalisedModelValues.highValue;
  959. this.outputModelChangeSubject.next({
  960. value: this.value,
  961. highValue: this.highValue,
  962. forceChange: true,
  963. userEventInitiated: false
  964. });
  965. }
  966. };
  967. SliderComponent.prototype.onChangeOptions = function () {
  968. if (!this.initHasRun) {
  969. return;
  970. }
  971. var previousInputEventsInterval = this.viewOptions.inputEventsInterval;
  972. var previousOutputEventsInterval = this.viewOptions.outputEventsInterval;
  973. this.applyOptions();
  974. if (previousInputEventsInterval !== this.viewOptions.inputEventsInterval) {
  975. this.unsubscribeInputModelChangeSubject();
  976. this.subscribeInputModelChangeSubject(this.viewOptions.inputEventsInterval);
  977. }
  978. if (previousOutputEventsInterval !== this.viewOptions.outputEventsInterval) {
  979. this.unsubscribeInputModelChangeSubject();
  980. this.subscribeInputModelChangeSubject(this.viewOptions.outputEventsInterval);
  981. }
  982. this.renormaliseModelValues();
  983. this.viewLowValue = this.modelValueToViewValue(this.value);
  984. if (this.range) {
  985. this.viewHighValue = this.modelValueToViewValue(this.highValue);
  986. }
  987. else {
  988. this.viewHighValue = null;
  989. }
  990. this.resetSlider();
  991. };
  992. SliderComponent.prototype.applyOptions = function () {
  993. this.viewOptions = new Options();
  994. Object.assign(this.viewOptions, this.options);
  995. this.viewOptions.draggableRange = this.range && this.viewOptions.draggableRange;
  996. this.viewOptions.draggableRangeOnly = this.range && this.viewOptions.draggableRangeOnly;
  997. if (this.viewOptions.draggableRangeOnly) {
  998. this.viewOptions.draggableRange = true;
  999. }
  1000. this.viewOptions.showTicks = this.viewOptions.showTicks ||
  1001. this.viewOptions.showTicksValues ||
  1002. !ValueHelper.isNullOrUndefined(this.viewOptions.ticksArray);
  1003. if (this.viewOptions.showTicks &&
  1004. (!ValueHelper.isNullOrUndefined(this.viewOptions.tickStep) || !ValueHelper.isNullOrUndefined(this.viewOptions.ticksArray))) {
  1005. this.intermediateTicks = true;
  1006. }
  1007. this.viewOptions.showSelectionBar = this.viewOptions.showSelectionBar ||
  1008. this.viewOptions.showSelectionBarEnd ||
  1009. !ValueHelper.isNullOrUndefined(this.viewOptions.showSelectionBarFromValue);
  1010. if (!ValueHelper.isNullOrUndefined(this.viewOptions.stepsArray)) {
  1011. this.applyStepsArrayOptions();
  1012. }
  1013. else {
  1014. this.applyFloorCeilOptions();
  1015. }
  1016. if (ValueHelper.isNullOrUndefined(this.viewOptions.combineLabels)) {
  1017. this.viewOptions.combineLabels = function (minValue, maxValue) {
  1018. return minValue + ' - ' + maxValue;
  1019. };
  1020. }
  1021. if (this.viewOptions.logScale && this.viewOptions.floor === 0) {
  1022. throw Error('Can\'t use floor=0 with logarithmic scale');
  1023. }
  1024. };
  1025. SliderComponent.prototype.applyStepsArrayOptions = function () {
  1026. var _this = this;
  1027. this.viewOptions.floor = 0;
  1028. this.viewOptions.ceil = this.viewOptions.stepsArray.length - 1;
  1029. this.viewOptions.step = 1;
  1030. if (ValueHelper.isNullOrUndefined(this.viewOptions.translate)) {
  1031. this.viewOptions.translate = function (modelValue) {
  1032. if (_this.viewOptions.bindIndexForStepsArray) {
  1033. return String(_this.getStepValue(modelValue));
  1034. }
  1035. return String(modelValue);
  1036. };
  1037. }
  1038. this.viewOptions.getLegend = function (index) {
  1039. var step = _this.viewOptions.stepsArray[index];
  1040. return step.legend;
  1041. };
  1042. };
  1043. SliderComponent.prototype.applyFloorCeilOptions = function () {
  1044. if (ValueHelper.isNullOrUndefined(this.viewOptions.step)) {
  1045. this.viewOptions.step = 1;
  1046. }
  1047. else {
  1048. this.viewOptions.step = +this.viewOptions.step;
  1049. if (this.viewOptions.step <= 0) {
  1050. this.viewOptions.step = 1;
  1051. }
  1052. }
  1053. if (ValueHelper.isNullOrUndefined(this.viewOptions.ceil) ||
  1054. ValueHelper.isNullOrUndefined(this.viewOptions.floor)) {
  1055. throw Error('floor and ceil options must be supplied');
  1056. }
  1057. this.viewOptions.ceil = +this.viewOptions.ceil;
  1058. this.viewOptions.floor = +this.viewOptions.floor;
  1059. if (ValueHelper.isNullOrUndefined(this.viewOptions.translate)) {
  1060. this.viewOptions.translate = function (value) { return String(value); };
  1061. }
  1062. };
  1063. SliderComponent.prototype.resetSlider = function () {
  1064. this.manageElementsStyle();
  1065. this.addAccessibility();
  1066. this.updateCeilLabel();
  1067. this.updateFloorLabel();
  1068. this.unbindEvents();
  1069. this.manageEventsBindings();
  1070. this.updateDisabledState();
  1071. this.calculateViewDimensions();
  1072. this.refocusPointerIfNeeded();
  1073. };
  1074. SliderComponent.prototype.focusPointer = function (pointerType) {
  1075. if (pointerType !== PointerType.Min && pointerType !== PointerType.Max) {
  1076. pointerType = PointerType.Min;
  1077. }
  1078. if (pointerType === PointerType.Min) {
  1079. this.minHandleElement.focus();
  1080. }
  1081. else if (this.range && pointerType === PointerType.Max) {
  1082. this.maxHandleElement.focus();
  1083. }
  1084. };
  1085. SliderComponent.prototype.refocusPointerIfNeeded = function () {
  1086. if (!ValueHelper.isNullOrUndefined(this.currentFocusPointer)) {
  1087. this.onPointerFocus(this.currentFocusPointer);
  1088. var element = this.getPointerElement(this.currentFocusPointer);
  1089. element.focus();
  1090. }
  1091. };
  1092. SliderComponent.prototype.manageElementsStyle = function () {
  1093. var _this = this;
  1094. this.updateScale();
  1095. this.floorLabelElement.setAlwaysHide(this.viewOptions.showTicksValues || this.viewOptions.hideLimitLabels);
  1096. this.ceilLabelElement.setAlwaysHide(this.viewOptions.showTicksValues || this.viewOptions.hideLimitLabels);
  1097. var hideLabelsForTicks = this.viewOptions.showTicksValues && !this.intermediateTicks;
  1098. this.minHandleLabelElement.setAlwaysHide(hideLabelsForTicks || this.viewOptions.hidePointerLabels);
  1099. this.maxHandleLabelElement.setAlwaysHide(hideLabelsForTicks || !this.range || this.viewOptions.hidePointerLabels);
  1100. this.combinedLabelElement.setAlwaysHide(hideLabelsForTicks || !this.range || this.viewOptions.hidePointerLabels);
  1101. this.selectionBarElement.setAlwaysHide(!this.range && !this.viewOptions.showSelectionBar);
  1102. this.leftOuterSelectionBarElement.setAlwaysHide(!this.range || !this.viewOptions.showOuterSelectionBars);
  1103. this.rightOuterSelectionBarElement.setAlwaysHide(!this.range || !this.viewOptions.showOuterSelectionBars);
  1104. this.fullBarTransparentClass = this.range && this.viewOptions.showOuterSelectionBars;
  1105. this.selectionBarDraggableClass = this.viewOptions.draggableRange && !this.viewOptions.onlyBindHandles;
  1106. this.ticksUnderValuesClass = this.intermediateTicks && this.options.showTicksValues;
  1107. if (this.sliderElementVerticalClass !== this.viewOptions.vertical) {
  1108. this.updateVerticalState();
  1109. setTimeout(function () { _this.resetSlider(); });
  1110. }
  1111. if (this.sliderElementAnimateClass !== this.viewOptions.animate) {
  1112. setTimeout(function () { _this.sliderElementAnimateClass = _this.viewOptions.animate; });
  1113. }
  1114. };
  1115. SliderComponent.prototype.manageEventsBindings = function () {
  1116. if (this.viewOptions.disabled || this.viewOptions.readOnly) {
  1117. this.unbindEvents();
  1118. }
  1119. else {
  1120. this.bindEvents();
  1121. }
  1122. };
  1123. SliderComponent.prototype.updateDisabledState = function () {
  1124. this.sliderElementDisabledAttr = this.viewOptions.disabled ? 'disabled' : null;
  1125. };
  1126. SliderComponent.prototype.updateVerticalState = function () {
  1127. this.sliderElementVerticalClass = this.viewOptions.vertical;
  1128. try {
  1129. for (var _a = __values(this.getAllSliderElements()), _b = _a.next(); !_b.done; _b = _a.next()) {
  1130. var element = _b.value;
  1131. if (!ValueHelper.isNullOrUndefined(element)) {
  1132. element.setVertical(this.viewOptions.vertical);
  1133. }
  1134. }
  1135. }
  1136. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  1137. finally {
  1138. try {
  1139. if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
  1140. }
  1141. finally { if (e_2) throw e_2.error; }
  1142. }
  1143. var e_2, _c;
  1144. };
  1145. SliderComponent.prototype.updateScale = function () {
  1146. try {
  1147. for (var _a = __values(this.getAllSliderElements()), _b = _a.next(); !_b.done; _b = _a.next()) {
  1148. var element = _b.value;
  1149. element.setScale(this.viewOptions.scale);
  1150. }
  1151. }
  1152. catch (e_3_1) { e_3 = { error: e_3_1 }; }
  1153. finally {
  1154. try {
  1155. if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
  1156. }
  1157. finally { if (e_3) throw e_3.error; }
  1158. }
  1159. var e_3, _c;
  1160. };
  1161. SliderComponent.prototype.getAllSliderElements = function () {
  1162. return [this.leftOuterSelectionBarElement,
  1163. this.rightOuterSelectionBarElement,
  1164. this.fullBarElement,
  1165. this.selectionBarElement,
  1166. this.minHandleElement,
  1167. this.maxHandleElement,
  1168. this.floorLabelElement,
  1169. this.ceilLabelElement,
  1170. this.minHandleLabelElement,
  1171. this.maxHandleLabelElement,
  1172. this.combinedLabelElement,
  1173. this.ticksElement
  1174. ];
  1175. };
  1176. SliderComponent.prototype.initHandles = function () {
  1177. this.updateLowHandle(this.valueToPosition(this.viewLowValue));
  1178. if (this.range) {
  1179. this.updateHighHandle(this.valueToPosition(this.viewHighValue));
  1180. }
  1181. this.updateSelectionBar();
  1182. if (this.range) {
  1183. this.updateCombinedLabel();
  1184. }
  1185. this.updateTicksScale();
  1186. };
  1187. SliderComponent.prototype.addAccessibility = function () {
  1188. this.updateAriaAttributes();
  1189. this.minHandleElement.role = 'slider';
  1190. if (this.viewOptions.keyboardSupport &&
  1191. !(this.viewOptions.readOnly || this.viewOptions.disabled)) {
  1192. this.minHandleElement.tabindex = '0';
  1193. }
  1194. else {
  1195. this.minHandleElement.tabindex = '';
  1196. }
  1197. if (this.viewOptions.vertical) {
  1198. this.minHandleElement.ariaOrientation = 'vertical';
  1199. }
  1200. if (!ValueHelper.isNullOrUndefined(this.viewOptions.ariaLabel)) {
  1201. this.minHandleElement.ariaLabel = this.viewOptions.ariaLabel;
  1202. }
  1203. else if (!ValueHelper.isNullOrUndefined(this.viewOptions.ariaLabelledBy)) {
  1204. this.minHandleElement.ariaLabelledBy = this.viewOptions.ariaLabelledBy;
  1205. }
  1206. if (this.range) {
  1207. this.maxHandleElement.role = 'slider';
  1208. if (this.viewOptions.keyboardSupport &&
  1209. !(this.viewOptions.readOnly || this.viewOptions.disabled)) {
  1210. this.maxHandleElement.tabindex = '0';
  1211. }
  1212. else {
  1213. this.maxHandleElement.tabindex = '';
  1214. }
  1215. this.maxHandleElement.ariaOrientation = this.viewOptions.vertical ? 'vertical' : 'horizontal';
  1216. if (!ValueHelper.isNullOrUndefined(this.viewOptions.ariaLabelHigh)) {
  1217. this.maxHandleElement.ariaLabel = this.viewOptions.ariaLabelHigh;
  1218. }
  1219. else if (!ValueHelper.isNullOrUndefined(this.viewOptions.ariaLabelledByHigh)) {
  1220. this.maxHandleElement.ariaLabelledBy = this.viewOptions.ariaLabelledByHigh;
  1221. }
  1222. }
  1223. };
  1224. SliderComponent.prototype.updateAriaAttributes = function () {
  1225. this.minHandleElement.ariaValueNow = (+this.value).toString();
  1226. this.minHandleElement.ariaValueText = this.viewOptions.translate(+this.value, LabelType.Low);
  1227. this.minHandleElement.ariaValueMin = this.viewOptions.floor.toString();
  1228. this.minHandleElement.ariaValueMax = this.viewOptions.ceil.toString();
  1229. if (this.range) {
  1230. this.maxHandleElement.ariaValueNow = (+this.highValue).toString();
  1231. this.maxHandleElement.ariaValueText = this.viewOptions.translate(+this.highValue, LabelType.High);
  1232. this.maxHandleElement.ariaValueMin = this.viewOptions.floor.toString();
  1233. this.maxHandleElement.ariaValueMax = this.viewOptions.ceil.toString();
  1234. }
  1235. };
  1236. SliderComponent.prototype.calculateViewDimensions = function () {
  1237. if (!ValueHelper.isNullOrUndefined(this.viewOptions.handleDimension)) {
  1238. this.minHandleElement.setDimension(this.viewOptions.handleDimension);
  1239. }
  1240. else {
  1241. this.minHandleElement.calculateDimension();
  1242. }
  1243. var handleWidth = this.minHandleElement.dimension;
  1244. this.handleHalfDimension = handleWidth / 2;
  1245. if (!ValueHelper.isNullOrUndefined(this.viewOptions.barDimension)) {
  1246. this.fullBarElement.setDimension(this.viewOptions.barDimension);
  1247. }
  1248. else {
  1249. this.fullBarElement.calculateDimension();
  1250. }
  1251. this.maxHandlePosition = this.fullBarElement.dimension - handleWidth;
  1252. if (this.initHasRun) {
  1253. this.updateFloorLabel();
  1254. this.updateCeilLabel();
  1255. this.initHandles();
  1256. }
  1257. };
  1258. SliderComponent.prototype.calculateViewDimensionsAndDetectChanges = function () {
  1259. this.calculateViewDimensions();
  1260. this.changeDetectionRef.detectChanges();
  1261. };
  1262. SliderComponent.prototype.updateTicksScale = function () {
  1263. var _this = this;
  1264. if (!this.viewOptions.showTicks) {
  1265. return;
  1266. }
  1267. var ticksArray = !ValueHelper.isNullOrUndefined(this.viewOptions.ticksArray)
  1268. ? this.viewOptions.ticksArray
  1269. : this.getTicksArray();
  1270. var translate = this.viewOptions.vertical ? 'translateY' : 'translateX';
  1271. if (this.viewOptions.rightToLeft) {
  1272. ticksArray.reverse();
  1273. }
  1274. var newTicks = ticksArray.map(function (value) {
  1275. var position = _this.valueToPosition(value);
  1276. if (_this.viewOptions.vertical) {
  1277. position = _this.maxHandlePosition - position;
  1278. }
  1279. var translation = translate + '(' + Math.round(position) + 'px)';
  1280. var tick = new Tick();
  1281. tick.selected = _this.isTickSelected(value);
  1282. tick.style = {
  1283. '-webkit-transform': translation,
  1284. '-moz-transform': translation,
  1285. '-o-transform': translation,
  1286. '-ms-transform': translation,
  1287. transform: translation,
  1288. };
  1289. if (tick.selected && !ValueHelper.isNullOrUndefined(_this.viewOptions.getSelectionBarColor)) {
  1290. tick.style['background-color'] = _this.getSelectionBarColor();
  1291. }
  1292. if (!tick.selected && !ValueHelper.isNullOrUndefined(_this.viewOptions.getTickColor)) {
  1293. tick.style['background-color'] = _this.getTickColor(value);
  1294. }
  1295. if (!ValueHelper.isNullOrUndefined(_this.viewOptions.ticksTooltip)) {
  1296. tick.tooltip = _this.viewOptions.ticksTooltip(value);
  1297. tick.tooltipPlacement = _this.viewOptions.vertical ? 'right' : 'top';
  1298. }
  1299. if (_this.viewOptions.showTicksValues && (value % _this.viewOptions.tickValueStep === 0)) {
  1300. tick.value = _this.getDisplayValue(value, LabelType.TickValue);
  1301. if (!ValueHelper.isNullOrUndefined(_this.viewOptions.ticksValuesTooltip)) {
  1302. tick.valueTooltip = _this.viewOptions.ticksValuesTooltip(value);
  1303. tick.valueTooltipPlacement = _this.viewOptions.vertical
  1304. ? 'right'
  1305. : 'top';
  1306. }
  1307. }
  1308. if (!ValueHelper.isNullOrUndefined(_this.viewOptions.getLegend)) {
  1309. var legend = _this.viewOptions.getLegend(value);
  1310. if (!ValueHelper.isNullOrUndefined(legend)) {
  1311. tick.legend = legend;
  1312. }
  1313. }
  1314. return tick;
  1315. });
  1316. if (!ValueHelper.isNullOrUndefined(this.ticks) && this.ticks.length === newTicks.length) {
  1317. for (var i = 0; i < newTicks.length; ++i) {
  1318. Object.assign(this.ticks[i], newTicks[i]);
  1319. }
  1320. }
  1321. else {
  1322. this.ticks = newTicks;
  1323. }
  1324. this.changeDetectionRef.detectChanges();
  1325. };
  1326. SliderComponent.prototype.getTicksArray = function () {
  1327. var step = (!ValueHelper.isNullOrUndefined(this.viewOptions.tickStep)) ? this.viewOptions.tickStep : this.viewOptions.step;
  1328. var ticksArray = [];
  1329. for (var value = this.viewOptions.floor; value <= this.viewOptions.ceil; value += step) {
  1330. ticksArray.push(value);
  1331. }
  1332. return ticksArray;
  1333. };
  1334. SliderComponent.prototype.isTickSelected = function (value) {
  1335. if (!this.range) {
  1336. if (!ValueHelper.isNullOrUndefined(this.viewOptions.showSelectionBarFromValue)) {
  1337. var center = this.viewOptions.showSelectionBarFromValue;
  1338. if (this.viewLowValue > center &&
  1339. value >= center &&
  1340. value <= this.viewLowValue) {
  1341. return true;
  1342. }
  1343. else if (this.viewLowValue < center &&
  1344. value <= center &&
  1345. value >= this.viewLowValue) {
  1346. return true;
  1347. }
  1348. }
  1349. else if (this.viewOptions.showSelectionBarEnd) {
  1350. if (value >= this.viewLowValue) {
  1351. return true;
  1352. }
  1353. }
  1354. else if (this.viewOptions.showSelectionBar && value <= this.viewLowValue) {
  1355. return true;
  1356. }
  1357. }
  1358. if (this.range && value >= this.viewLowValue && value <= this.viewHighValue) {
  1359. return true;
  1360. }
  1361. return false;
  1362. };
  1363. SliderComponent.prototype.updateFloorLabel = function () {
  1364. if (!this.floorLabelElement.alwaysHide) {
  1365. this.floorLabelElement.setValue(this.getDisplayValue(this.viewOptions.floor, LabelType.Floor));
  1366. this.floorLabelElement.calculateDimension();
  1367. var position = this.viewOptions.rightToLeft
  1368. ? this.fullBarElement.dimension - this.floorLabelElement.dimension
  1369. : 0;
  1370. this.floorLabelElement.setPosition(position);
  1371. }
  1372. };
  1373. SliderComponent.prototype.updateCeilLabel = function () {
  1374. if (!this.ceilLabelElement.alwaysHide) {
  1375. this.ceilLabelElement.setValue(this.getDisplayValue(this.viewOptions.ceil, LabelType.Ceil));
  1376. this.ceilLabelElement.calculateDimension();
  1377. var position = this.viewOptions.rightToLeft
  1378. ? 0
  1379. : this.fullBarElement.dimension - this.ceilLabelElement.dimension;
  1380. this.ceilLabelElement.setPosition(position);
  1381. }
  1382. };
  1383. SliderComponent.prototype.updateHandles = function (which, newPos) {
  1384. if (which === PointerType.Min) {
  1385. this.updateLowHandle(newPos);
  1386. }
  1387. else if (which === PointerType.Max) {
  1388. this.updateHighHandle(newPos);
  1389. }
  1390. this.updateSelectionBar();
  1391. this.updateTicksScale();
  1392. if (this.range) {
  1393. this.updateCombinedLabel();
  1394. }
  1395. };
  1396. SliderComponent.prototype.getHandleLabelPos = function (labelType, newPos) {
  1397. var labelDimension = (labelType === PointerType.Min)
  1398. ? this.minHandleLabelElement.dimension
  1399. : this.maxHandleLabelElement.dimension;
  1400. var nearHandlePos = newPos - labelDimension / 2 + this.handleHalfDimension;
  1401. var endOfBarPos = this.fullBarElement.dimension - labelDimension;
  1402. if (!this.viewOptions.boundPointerLabels) {
  1403. return nearHandlePos;
  1404. }
  1405. if ((this.viewOptions.rightToLeft && labelType === PointerType.Min) ||
  1406. (!this.viewOptions.rightToLeft && labelType === PointerType.Max)) {
  1407. return Math.min(nearHandlePos, endOfBarPos);
  1408. }
  1409. else {
  1410. return Math.min(Math.max(nearHandlePos, 0), endOfBarPos);
  1411. }
  1412. };
  1413. SliderComponent.prototype.updateLowHandle = function (newPos) {
  1414. this.minHandleElement.setPosition(newPos);
  1415. this.minHandleLabelElement.setValue(this.getDisplayValue(this.viewLowValue, LabelType.Low));
  1416. this.minHandleLabelElement.setPosition(this.getHandleLabelPos(PointerType.Min, newPos));
  1417. if (!ValueHelper.isNullOrUndefined(this.viewOptions.getPointerColor)) {
  1418. this.minPointerStyle = {
  1419. backgroundColor: this.getPointerColor(PointerType.Min),
  1420. };
  1421. }
  1422. if (this.viewOptions.autoHideLimitLabels) {
  1423. this.updateFloorAndCeilLabelsVisibility();
  1424. }
  1425. };
  1426. SliderComponent.prototype.updateHighHandle = function (newPos) {
  1427. this.maxHandleElement.setPosition(newPos);
  1428. this.maxHandleLabelElement.setValue(this.getDisplayValue(this.viewHighValue, LabelType.High));
  1429. this.maxHandleLabelElement.setPosition(this.getHandleLabelPos(PointerType.Max, newPos));
  1430. if (!ValueHelper.isNullOrUndefined(this.viewOptions.getPointerColor)) {
  1431. this.maxPointerStyle = {
  1432. backgroundColor: this.getPointerColor(PointerType.Max),
  1433. };
  1434. }
  1435. if (this.viewOptions.autoHideLimitLabels) {
  1436. this.updateFloorAndCeilLabelsVisibility();
  1437. }
  1438. };
  1439. SliderComponent.prototype.updateFloorAndCeilLabelsVisibility = function () {
  1440. if (this.viewOptions.hidePointerLabels) {
  1441. return;
  1442. }
  1443. var floorLabelHidden = false;
  1444. var ceilLabelHidden = false;
  1445. var isMinLabelAtFloor = this.isLabelBelowFloorLabel(this.minHandleLabelElement);
  1446. var isMinLabelAtCeil = this.isLabelAboveCeilLabel(this.minHandleLabelElement);
  1447. var isMaxLabelAtCeil = this.isLabelAboveCeilLabel(this.maxHandleLabelElement);
  1448. var isCombinedLabelAtFloor = this.isLabelBelowFloorLabel(this.combinedLabelElement);
  1449. var isCombinedLabelAtCeil = this.isLabelAboveCeilLabel(this.combinedLabelElement);
  1450. if (isMinLabelAtFloor) {
  1451. floorLabelHidden = true;
  1452. this.floorLabelElement.hide();
  1453. }
  1454. else {
  1455. floorLabelHidden = false;
  1456. this.floorLabelElement.show();
  1457. }
  1458. if (isMinLabelAtCeil) {
  1459. ceilLabelHidden = true;
  1460. this.ceilLabelElement.hide();
  1461. }
  1462. else {
  1463. ceilLabelHidden = false;
  1464. this.ceilLabelElement.show();
  1465. }
  1466. if (this.range) {
  1467. var hideCeil = this.combinedLabelElement.isVisible() ? isCombinedLabelAtCeil : isMaxLabelAtCeil;
  1468. var hideFloor = this.combinedLabelElement.isVisible() ? isCombinedLabelAtFloor : isMinLabelAtFloor;
  1469. if (hideCeil) {
  1470. this.ceilLabelElement.hide();
  1471. }
  1472. else if (!ceilLabelHidden) {
  1473. this.ceilLabelElement.show();
  1474. }
  1475. if (hideFloor) {
  1476. this.floorLabelElement.hide();
  1477. }
  1478. else if (!floorLabelHidden) {
  1479. this.floorLabelElement.show();
  1480. }
  1481. }
  1482. };
  1483. SliderComponent.prototype.isLabelBelowFloorLabel = function (label) {
  1484. var pos = label.position;
  1485. var dim = label.dimension;
  1486. var floorPos = this.floorLabelElement.position;
  1487. var floorDim = this.floorLabelElement.dimension;
  1488. return this.viewOptions.rightToLeft
  1489. ? pos + dim >= floorPos - 2
  1490. : pos <= floorPos + floorDim + 2;
  1491. };
  1492. SliderComponent.prototype.isLabelAboveCeilLabel = function (label) {
  1493. var pos = label.position;
  1494. var dim = label.dimension;
  1495. var ceilPos = this.ceilLabelElement.position;
  1496. var ceilDim = this.ceilLabelElement.dimension;
  1497. return this.viewOptions.rightToLeft
  1498. ? pos <= ceilPos + ceilDim + 2
  1499. : pos + dim >= ceilPos - 2;
  1500. };
  1501. SliderComponent.prototype.updateSelectionBar = function () {
  1502. var position = 0;
  1503. var dimension = 0;
  1504. var isSelectionBarFromRight = this.viewOptions.rightToLeft
  1505. ? !this.viewOptions.showSelectionBarEnd
  1506. : this.viewOptions.showSelectionBarEnd;
  1507. var positionForRange = this.viewOptions.rightToLeft
  1508. ? this.maxHandleElement.position + this.handleHalfDimension
  1509. : this.minHandleElement.position + this.handleHalfDimension;
  1510. if (this.range) {
  1511. dimension = Math.abs(this.maxHandleElement.position - this.minHandleElement.position);
  1512. position = positionForRange;
  1513. }
  1514. else {
  1515. if (!ValueHelper.isNullOrUndefined(this.viewOptions.showSelectionBarFromValue)) {
  1516. var center = this.viewOptions.showSelectionBarFromValue;
  1517. var centerPosition = this.valueToPosition(center);
  1518. var isModelGreaterThanCenter = this.viewOptions.rightToLeft
  1519. ? this.viewLowValue <= center
  1520. : this.viewLowValue > center;
  1521. if (isModelGreaterThanCenter) {
  1522. dimension = this.minHandleElement.position - centerPosition;
  1523. position = centerPosition + this.handleHalfDimension;
  1524. }
  1525. else {
  1526. dimension = centerPosition - this.minHandleElement.position;
  1527. position = this.minHandleElement.position + this.handleHalfDimension;
  1528. }
  1529. }
  1530. else if (isSelectionBarFromRight) {
  1531. dimension = Math.ceil(Math.abs(this.maxHandlePosition - this.minHandleElement.position) + this.handleHalfDimension);
  1532. position = Math.floor(this.minHandleElement.position + this.handleHalfDimension);
  1533. }
  1534. else {
  1535. dimension = this.minHandleElement.position + this.handleHalfDimension;
  1536. position = 0;
  1537. }
  1538. }
  1539. this.selectionBarElement.setDimension(dimension);
  1540. this.selectionBarElement.setPosition(position);
  1541. if (this.range && this.viewOptions.showOuterSelectionBars) {
  1542. if (this.viewOptions.rightToLeft) {
  1543. this.rightOuterSelectionBarElement.setDimension(position);
  1544. this.rightOuterSelectionBarElement.setPosition(0);
  1545. this.fullBarElement.calculateDimension();
  1546. this.leftOuterSelectionBarElement.setDimension(this.fullBarElement.dimension - (position + dimension));
  1547. this.leftOuterSelectionBarElement.setPosition(position + dimension);
  1548. }
  1549. else {
  1550. this.leftOuterSelectionBarElement.setDimension(position);
  1551. this.leftOuterSelectionBarElement.setPosition(0);
  1552. this.fullBarElement.calculateDimension();
  1553. this.rightOuterSelectionBarElement.setDimension(this.fullBarElement.dimension - (position + dimension));
  1554. this.rightOuterSelectionBarElement.setPosition(position + dimension);
  1555. }
  1556. }
  1557. if (!ValueHelper.isNullOrUndefined(this.viewOptions.getSelectionBarColor)) {
  1558. var color = this.getSelectionBarColor();
  1559. this.barStyle = {
  1560. backgroundColor: color,
  1561. };
  1562. }
  1563. else if (!ValueHelper.isNullOrUndefined(this.viewOptions.selectionBarGradient)) {
  1564. var offset = (!ValueHelper.isNullOrUndefined(this.viewOptions.showSelectionBarFromValue))
  1565. ? this.valueToPosition(this.viewOptions.showSelectionBarFromValue)
  1566. : 0;
  1567. var reversed = (offset - position > 0 && !isSelectionBarFromRight) || (offset - position <= 0 && isSelectionBarFromRight);
  1568. var direction = this.viewOptions.vertical
  1569. ? reversed ? 'bottom' : 'top'
  1570. : reversed ? 'left' : 'right';
  1571. this.barStyle = {
  1572. backgroundImage: 'linear-gradient(to ' +
  1573. direction +
  1574. ', ' +
  1575. this.viewOptions.selectionBarGradient.from +
  1576. ' 0%,' +
  1577. this.viewOptions.selectionBarGradient.to +
  1578. ' 100%)',
  1579. };
  1580. if (this.viewOptions.vertical) {
  1581. this.barStyle.backgroundPosition =
  1582. 'center ' +
  1583. (offset +
  1584. dimension +
  1585. position +
  1586. (reversed ? -this.handleHalfDimension : 0)) +
  1587. 'px';
  1588. this.barStyle.backgroundSize =
  1589. '100% ' + (this.fullBarElement.dimension - this.handleHalfDimension) + 'px';
  1590. }
  1591. else {
  1592. this.barStyle.backgroundPosition =
  1593. offset -
  1594. position +
  1595. (reversed ? this.handleHalfDimension : 0) +
  1596. 'px center';
  1597. this.barStyle.backgroundSize =
  1598. this.fullBarElement.dimension - this.handleHalfDimension + 'px 100%';
  1599. }
  1600. }
  1601. };
  1602. SliderComponent.prototype.getSelectionBarColor = function () {
  1603. if (this.range) {
  1604. return this.viewOptions.getSelectionBarColor(this.value, this.highValue);
  1605. }
  1606. return this.viewOptions.getSelectionBarColor(this.value);
  1607. };
  1608. SliderComponent.prototype.getPointerColor = function (pointerType) {
  1609. if (pointerType === PointerType.Max) {
  1610. return this.viewOptions.getPointerColor(this.highValue, pointerType);
  1611. }
  1612. return this.viewOptions.getPointerColor(this.value, pointerType);
  1613. };
  1614. SliderComponent.prototype.getTickColor = function (value) {
  1615. return this.viewOptions.getTickColor(value);
  1616. };
  1617. SliderComponent.prototype.updateCombinedLabel = function () {
  1618. var isLabelOverlap = null;
  1619. if (this.viewOptions.rightToLeft) {
  1620. isLabelOverlap =
  1621. this.minHandleLabelElement.position - this.minHandleLabelElement.dimension - 10 <= this.maxHandleLabelElement.position;
  1622. }
  1623. else {
  1624. isLabelOverlap =
  1625. this.minHandleLabelElement.position + this.minHandleLabelElement.dimension + 10 >= this.maxHandleLabelElement.position;
  1626. }
  1627. if (isLabelOverlap) {
  1628. var lowDisplayValue = this.getDisplayValue(this.viewLowValue, LabelType.Low);
  1629. var highDisplayValue = this.getDisplayValue(this.viewHighValue, LabelType.High);
  1630. var combinedLabelValue = this.viewOptions.rightToLeft
  1631. ? this.viewOptions.combineLabels(highDisplayValue, lowDisplayValue)
  1632. : this.viewOptions.combineLabels(lowDisplayValue, highDisplayValue);
  1633. this.combinedLabelElement.setValue(combinedLabelValue);
  1634. var pos = this.viewOptions.boundPointerLabels
  1635. ? Math.min(Math.max(this.selectionBarElement.position +
  1636. this.selectionBarElement.dimension / 2 -
  1637. this.combinedLabelElement.dimension / 2, 0), this.fullBarElement.dimension - this.combinedLabelElement.dimension)
  1638. : this.selectionBarElement.position + this.selectionBarElement.dimension / 2 - this.combinedLabelElement.dimension / 2;
  1639. this.combinedLabelElement.setPosition(pos);
  1640. this.minHandleLabelElement.hide();
  1641. this.maxHandleLabelElement.hide();
  1642. this.combinedLabelElement.show();
  1643. }
  1644. else {
  1645. this.updateHighHandle(this.valueToPosition(this.viewHighValue));
  1646. this.updateLowHandle(this.valueToPosition(this.viewLowValue));
  1647. this.maxHandleLabelElement.show();
  1648. this.minHandleLabelElement.show();
  1649. this.combinedLabelElement.hide();
  1650. }
  1651. if (this.viewOptions.autoHideLimitLabels) {
  1652. this.updateFloorAndCeilLabelsVisibility();
  1653. }
  1654. };
  1655. SliderComponent.prototype.getDisplayValue = function (value, which) {
  1656. if (!ValueHelper.isNullOrUndefined(this.viewOptions.stepsArray) && !this.viewOptions.bindIndexForStepsArray) {
  1657. value = this.getStepValue(value);
  1658. }
  1659. return this.viewOptions.translate(value, which);
  1660. };
  1661. SliderComponent.prototype.roundStep = function (value, customStep) {
  1662. var step = !ValueHelper.isNullOrUndefined(customStep) ? customStep : this.viewOptions.step;
  1663. var steppedDifference = MathHelper.roundToPrecisionLimit((value - this.viewOptions.floor) / step, this.viewOptions.precisionLimit);
  1664. steppedDifference = Math.round(steppedDifference) * step;
  1665. return MathHelper.roundToPrecisionLimit(this.viewOptions.floor + steppedDifference, this.viewOptions.precisionLimit);
  1666. };
  1667. SliderComponent.prototype.valueToPosition = function (val) {
  1668. var fn = ValueHelper.linearValueToPosition;
  1669. if (!ValueHelper.isNullOrUndefined(this.viewOptions.customValueToPosition)) {
  1670. fn = this.viewOptions.customValueToPosition;
  1671. }
  1672. else if (this.viewOptions.logScale) {
  1673. fn = ValueHelper.logValueToPosition;
  1674. }
  1675. val = MathHelper.clampToRange(val, this.viewOptions.floor, this.viewOptions.ceil);
  1676. var percent = fn(val, this.viewOptions.floor, this.viewOptions.ceil);
  1677. if (ValueHelper.isNullOrUndefined(percent)) {
  1678. percent = 0;
  1679. }
  1680. if (this.viewOptions.rightToLeft) {
  1681. percent = 1 - percent;
  1682. }
  1683. return percent * this.maxHandlePosition;
  1684. };
  1685. SliderComponent.prototype.positionToValue = function (position) {
  1686. var percent = position / this.maxHandlePosition;
  1687. if (this.viewOptions.rightToLeft) {
  1688. percent = 1 - percent;
  1689. }
  1690. var fn = ValueHelper.linearPositionToValue;
  1691. if (!ValueHelper.isNullOrUndefined(this.viewOptions.customPositionToValue)) {
  1692. fn = this.viewOptions.customPositionToValue;
  1693. }
  1694. else if (this.viewOptions.logScale) {
  1695. fn = ValueHelper.logPositionToValue;
  1696. }
  1697. var value = fn(percent, this.viewOptions.floor, this.viewOptions.ceil);
  1698. return !ValueHelper.isNullOrUndefined(value) ? value : 0;
  1699. };
  1700. SliderComponent.prototype.getEventXY = function (event, targetTouchId) {
  1701. if (event instanceof MouseEvent) {
  1702. return this.viewOptions.vertical ? event.clientY : event.clientX;
  1703. }
  1704. var touchIndex = 0;
  1705. var touches = event.touches;
  1706. if (!ValueHelper.isNullOrUndefined(targetTouchId)) {
  1707. for (var i = 0; i < touches.length; i++) {
  1708. if (touches[i].identifier === targetTouchId) {
  1709. touchIndex = i;
  1710. break;
  1711. }
  1712. }
  1713. }
  1714. return this.viewOptions.vertical ? touches[touchIndex].clientY : touches[touchIndex].clientX;
  1715. };
  1716. SliderComponent.prototype.getEventPosition = function (event, targetTouchId) {
  1717. var sliderElementBoundingRect = this.elementRef.nativeElement.getBoundingClientRect();
  1718. var sliderPos = this.viewOptions.vertical ?
  1719. sliderElementBoundingRect.bottom : sliderElementBoundingRect.left;
  1720. var eventPos = 0;
  1721. if (this.viewOptions.vertical) {
  1722. eventPos = -this.getEventXY(event, targetTouchId) + sliderPos;
  1723. }
  1724. else {
  1725. eventPos = this.getEventXY(event, targetTouchId) - sliderPos;
  1726. }
  1727. return eventPos * this.viewOptions.scale - this.handleHalfDimension;
  1728. };
  1729. SliderComponent.prototype.getNearestHandle = function (event) {
  1730. if (!this.range) {
  1731. return PointerType.Min;
  1732. }
  1733. var position = this.getEventPosition(event);
  1734. var distanceMin = Math.abs(position - this.minHandleElement.position);
  1735. var distanceMax = Math.abs(position - this.maxHandleElement.position);
  1736. if (distanceMin < distanceMax) {
  1737. return PointerType.Min;
  1738. }
  1739. else if (distanceMin > distanceMax) {
  1740. return PointerType.Max;
  1741. }
  1742. else if (!this.viewOptions.rightToLeft) {
  1743. return position < this.minHandleElement.position ? PointerType.Min : PointerType.Max;
  1744. }
  1745. return position > this.minHandleElement.position ? PointerType.Min : PointerType.Max;
  1746. };
  1747. SliderComponent.prototype.bindEvents = function () {
  1748. var _this = this;
  1749. var draggableRange = this.viewOptions.draggableRange;
  1750. if (!this.viewOptions.onlyBindHandles) {
  1751. this.selectionBarElement.on('mousedown', function (event) { return _this.onBarStart(null, draggableRange, event, true, true, true); });
  1752. }
  1753. if (this.viewOptions.draggableRangeOnly) {
  1754. this.minHandleElement.on('mousedown', function (event) { return _this.onBarStart(PointerType.Min, draggableRange, event, true, true); });
  1755. this.maxHandleElement.on('mousedown', function (event) { return _this.onBarStart(PointerType.Max, draggableRange, event, true, true); });
  1756. }
  1757. else {
  1758. this.minHandleElement.on('mousedown', function (event) { return _this.onStart(PointerType.Min, event, true, true); });
  1759. if (this.range) {
  1760. this.maxHandleElement.on('mousedown', function (event) { return _this.onStart(PointerType.Max, event, true, true); });
  1761. }
  1762. if (!this.viewOptions.onlyBindHandles) {
  1763. this.fullBarElement.on('mousedown', function (event) { return _this.onStart(null, event, true, true, true); });
  1764. this.ticksElement.on('mousedown', function (event) { return _this.onStart(null, event, true, true, true, true); });
  1765. }
  1766. }
  1767. if (!this.viewOptions.onlyBindHandles) {
  1768. this.selectionBarElement.onPassive('touchstart', function (event) { return _this.onBarStart(null, draggableRange, event, true, true, true); });
  1769. }
  1770. if (this.viewOptions.draggableRangeOnly) {
  1771. this.minHandleElement.onPassive('touchstart', function (event) { return _this.onBarStart(PointerType.Min, draggableRange, event, true, true); });
  1772. this.maxHandleElement.onPassive('touchstart', function (event) { return _this.onBarStart(PointerType.Max, draggableRange, event, true, true); });
  1773. }
  1774. else {
  1775. this.minHandleElement.onPassive('touchstart', function (event) { return _this.onStart(PointerType.Min, event, true, true); });
  1776. if (this.range) {
  1777. this.maxHandleElement.onPassive('touchstart', function (event) { return _this.onStart(PointerType.Max, event, true, true); });
  1778. }
  1779. if (!this.viewOptions.onlyBindHandles) {
  1780. this.fullBarElement.onPassive('touchstart', function (event) { return _this.onStart(null, event, true, true, true); });
  1781. this.ticksElement.onPassive('touchstart', function (event) { return _this.onStart(null, event, false, false, true, true); });
  1782. }
  1783. }
  1784. if (this.viewOptions.keyboardSupport) {
  1785. this.minHandleElement.on('focus', function () { return _this.onPointerFocus(PointerType.Min); });
  1786. if (this.range) {
  1787. this.maxHandleElement.on('focus', function () { return _this.onPointerFocus(PointerType.Max); });
  1788. }
  1789. }
  1790. };
  1791. SliderComponent.prototype.unbindEvents = function () {
  1792. this.unsubscribeOnMove();
  1793. this.unsubscribeOnEnd();
  1794. try {
  1795. for (var _a = __values(this.getAllSliderElements()), _b = _a.next(); !_b.done; _b = _a.next()) {
  1796. var element = _b.value;
  1797. element.off();
  1798. }
  1799. }
  1800. catch (e_4_1) { e_4 = { error: e_4_1 }; }
  1801. finally {
  1802. try {
  1803. if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
  1804. }
  1805. finally { if (e_4) throw e_4.error; }
  1806. }
  1807. var e_4, _c;
  1808. };
  1809. SliderComponent.prototype.onBarStart = function (pointerType, draggableRange, event, bindMove, bindEnd, simulateImmediateMove, simulateImmediateEnd) {
  1810. if (draggableRange) {
  1811. this.onDragStart(pointerType, event, bindMove, bindEnd);
  1812. }
  1813. else {
  1814. this.onStart(pointerType, event, bindMove, bindEnd, simulateImmediateMove, simulateImmediateEnd);
  1815. }
  1816. };
  1817. SliderComponent.prototype.onStart = function (pointerType, event, bindMove, bindEnd, simulateImmediateMove, simulateImmediateEnd) {
  1818. var _this = this;
  1819. event.stopPropagation();
  1820. if (!CompatibilityHelper.isTouchEvent(event) || !detectPassiveEvents.hasSupport) {
  1821. event.preventDefault();
  1822. }
  1823. this.calculateViewDimensions();
  1824. if (ValueHelper.isNullOrUndefined(pointerType)) {
  1825. pointerType = this.getNearestHandle(event);
  1826. }
  1827. this.currentTrackingPointer = pointerType;
  1828. var pointerElement = this.getPointerElement(pointerType);
  1829. pointerElement.active = true;
  1830. if (this.viewOptions.keyboardSupport) {
  1831. pointerElement.focus();
  1832. }
  1833. if (bindMove) {
  1834. this.unsubscribeOnMove();
  1835. var onMoveCallback = function (e) { return _this.dragging.active ? _this.onDragMove(e) : _this.onMove(e); };
  1836. if (CompatibilityHelper.isTouchEvent(event)) {
  1837. this.onMoveEventListener = this.eventListenerHelper.attachPassiveEventListener(document, 'touchmove', onMoveCallback, this.viewOptions.touchEventsInterval);
  1838. }
  1839. else {
  1840. this.onMoveEventListener = this.eventListenerHelper.attachEventListener(document, 'mousemove', onMoveCallback, this.viewOptions.mouseEventsInterval);
  1841. }
  1842. }
  1843. if (bindEnd) {
  1844. this.unsubscribeOnEnd();
  1845. var onEndCallback = function (e) { return _this.onEnd(e); };
  1846. if (CompatibilityHelper.isTouchEvent(event)) {
  1847. this.onEndEventListener = this.eventListenerHelper.attachPassiveEventListener(document, 'touchend', onEndCallback);
  1848. }
  1849. else {
  1850. this.onEndEventListener = this.eventListenerHelper.attachEventListener(document, 'mouseup', onEndCallback);
  1851. }
  1852. }
  1853. this.userChangeStart.emit(this.getChangeContext());
  1854. if (CompatibilityHelper.isTouchEvent(event) && !ValueHelper.isNullOrUndefined(((event)).changedTouches)) {
  1855. if (ValueHelper.isNullOrUndefined(this.touchId)) {
  1856. this.touchId = ((event)).changedTouches[0].identifier;
  1857. }
  1858. }
  1859. if (simulateImmediateMove) {
  1860. this.onMove(event, true);
  1861. }
  1862. if (simulateImmediateEnd) {
  1863. this.onEnd(event);
  1864. }
  1865. };
  1866. SliderComponent.prototype.onMove = function (event, fromTick) {
  1867. var touchForThisSlider = null;
  1868. if (CompatibilityHelper.isTouchEvent(event)) {
  1869. var changedTouches = ((event)).changedTouches;
  1870. for (var i = 0; i < changedTouches.length; i++) {
  1871. if (changedTouches[i].identifier === this.touchId) {
  1872. touchForThisSlider = changedTouches[i];
  1873. break;
  1874. }
  1875. }
  1876. if (ValueHelper.isNullOrUndefined(touchForThisSlider)) {
  1877. return;
  1878. }
  1879. }
  1880. var newPos = !ValueHelper.isNullOrUndefined(touchForThisSlider)
  1881. ? this.getEventPosition(event, touchForThisSlider.identifier)
  1882. : this.getEventPosition(event);
  1883. var newValue;
  1884. var ceilValue = this.viewOptions.rightToLeft
  1885. ? this.viewOptions.floor
  1886. : this.viewOptions.ceil;
  1887. var floorValue = this.viewOptions.rightToLeft ? this.viewOptions.ceil : this.viewOptions.floor;
  1888. if (newPos <= 0) {
  1889. newValue = floorValue;
  1890. }
  1891. else if (newPos >= this.maxHandlePosition) {
  1892. newValue = ceilValue;
  1893. }
  1894. else {
  1895. newValue = this.positionToValue(newPos);
  1896. if (fromTick && !ValueHelper.isNullOrUndefined(this.viewOptions.tickStep)) {
  1897. newValue = this.roundStep(newValue, this.viewOptions.tickStep);
  1898. }
  1899. else {
  1900. newValue = this.roundStep(newValue);
  1901. }
  1902. }
  1903. this.positionTrackingHandle(newValue);
  1904. };
  1905. SliderComponent.prototype.onEnd = function (event) {
  1906. if (CompatibilityHelper.isTouchEvent(event)) {
  1907. var changedTouches = ((event)).changedTouches;
  1908. if (changedTouches[0].identifier !== this.touchId) {
  1909. return;
  1910. }
  1911. }
  1912. this.touchId = null;
  1913. if (!this.viewOptions.keyboardSupport) {
  1914. this.minHandleElement.active = false;
  1915. this.maxHandleElement.active = false;
  1916. this.currentTrackingPointer = null;
  1917. }
  1918. this.dragging.active = false;
  1919. this.unsubscribeOnMove();
  1920. this.unsubscribeOnEnd();
  1921. this.userChangeEnd.emit(this.getChangeContext());
  1922. };
  1923. SliderComponent.prototype.onPointerFocus = function (pointerType) {
  1924. var _this = this;
  1925. var pointerElement = this.getPointerElement(pointerType);
  1926. pointerElement.on('blur', function () { return _this.onPointerBlur(pointerElement); });
  1927. pointerElement.on('keydown', function (event) { return _this.onKeyboardEvent(event); });
  1928. pointerElement.on('keyup', function () { return _this.onKeyUp(); });
  1929. pointerElement.active = true;
  1930. this.currentTrackingPointer = pointerType;
  1931. this.currentFocusPointer = pointerType;
  1932. this.firstKeyDown = true;
  1933. };
  1934. SliderComponent.prototype.onKeyUp = function () {
  1935. this.firstKeyDown = true;
  1936. this.userChangeEnd.emit(this.getChangeContext());
  1937. };
  1938. SliderComponent.prototype.onPointerBlur = function (pointer) {
  1939. pointer.off('blur');
  1940. pointer.off('keydown');
  1941. pointer.off('keyup');
  1942. pointer.active = false;
  1943. if (ValueHelper.isNullOrUndefined(this.touchId)) {
  1944. this.currentTrackingPointer = null;
  1945. this.currentFocusPointer = null;
  1946. }
  1947. };
  1948. SliderComponent.prototype.getKeyActions = function (currentValue) {
  1949. var valueRange = this.viewOptions.ceil - this.viewOptions.floor;
  1950. var increaseStep = currentValue + this.viewOptions.step;
  1951. var decreaseStep = currentValue - this.viewOptions.step;
  1952. var increasePage = currentValue + valueRange / 10;
  1953. var decreasePage = currentValue - valueRange / 10;
  1954. if (this.viewOptions.reversedControls) {
  1955. increaseStep = currentValue - this.viewOptions.step;
  1956. decreaseStep = currentValue + this.viewOptions.step;
  1957. increasePage = currentValue - valueRange / 10;
  1958. decreasePage = currentValue + valueRange / 10;
  1959. }
  1960. var actions = {
  1961. UP: increaseStep,
  1962. DOWN: decreaseStep,
  1963. LEFT: decreaseStep,
  1964. RIGHT: increaseStep,
  1965. PAGEUP: increasePage,
  1966. PAGEDOWN: decreasePage,
  1967. HOME: this.viewOptions.reversedControls ? this.viewOptions.ceil : this.viewOptions.floor,
  1968. END: this.viewOptions.reversedControls ? this.viewOptions.floor : this.viewOptions.ceil,
  1969. };
  1970. if (this.viewOptions.rightToLeft) {
  1971. actions["LEFT"] = increaseStep;
  1972. actions["RIGHT"] = decreaseStep;
  1973. if (this.viewOptions.vertical) {
  1974. actions["UP"] = decreaseStep;
  1975. actions["DOWN"] = increaseStep;
  1976. }
  1977. }
  1978. return actions;
  1979. };
  1980. SliderComponent.prototype.onKeyboardEvent = function (event) {
  1981. var currentValue = this.getCurrentTrackingValue();
  1982. var keyCode = !ValueHelper.isNullOrUndefined(event.keyCode)
  1983. ? event.keyCode
  1984. : event.which;
  1985. var keys = {
  1986. 38: 'UP',
  1987. 40: 'DOWN',
  1988. 37: 'LEFT',
  1989. 39: 'RIGHT',
  1990. 33: 'PAGEUP',
  1991. 34: 'PAGEDOWN',
  1992. 36: 'HOME',
  1993. 35: 'END',
  1994. };
  1995. var actions = this.getKeyActions(currentValue);
  1996. var key = keys[keyCode];
  1997. var action = actions[key];
  1998. if (ValueHelper.isNullOrUndefined(action) || ValueHelper.isNullOrUndefined(this.currentTrackingPointer)) {
  1999. return;
  2000. }
  2001. event.preventDefault();
  2002. if (this.firstKeyDown) {
  2003. this.firstKeyDown = false;
  2004. this.userChangeStart.emit(this.getChangeContext());
  2005. }
  2006. var actionValue = MathHelper.clampToRange(action, this.viewOptions.floor, this.viewOptions.ceil);
  2007. var newValue = this.roundStep(actionValue);
  2008. if (!this.viewOptions.draggableRangeOnly) {
  2009. this.positionTrackingHandle(newValue);
  2010. }
  2011. else {
  2012. var difference = this.viewHighValue - this.viewLowValue;
  2013. var newMinValue = void 0;
  2014. var newMaxValue = void 0;
  2015. if (this.currentTrackingPointer === PointerType.Min) {
  2016. newMinValue = newValue;
  2017. newMaxValue = newValue + difference;
  2018. if (newMaxValue > this.viewOptions.ceil) {
  2019. newMaxValue = this.viewOptions.ceil;
  2020. newMinValue = newMaxValue - difference;
  2021. }
  2022. }
  2023. else if (this.currentTrackingPointer === PointerType.Max) {
  2024. newMaxValue = newValue;
  2025. newMinValue = newValue - difference;
  2026. if (newMinValue < this.viewOptions.floor) {
  2027. newMinValue = this.viewOptions.floor;
  2028. newMaxValue = newMinValue + difference;
  2029. }
  2030. }
  2031. this.positionTrackingBar(newMinValue, newMaxValue);
  2032. }
  2033. };
  2034. SliderComponent.prototype.onDragStart = function (pointerType, event, bindMove, bindEnd) {
  2035. var position = this.getEventPosition(event);
  2036. this.dragging = new Dragging();
  2037. this.dragging.active = true;
  2038. this.dragging.value = this.positionToValue(position);
  2039. this.dragging.difference = this.viewHighValue - this.viewLowValue;
  2040. this.dragging.lowLimit = this.viewOptions.rightToLeft
  2041. ? this.minHandleElement.position - position
  2042. : position - this.minHandleElement.position;
  2043. this.dragging.highLimit = this.viewOptions.rightToLeft
  2044. ? position - this.maxHandleElement.position
  2045. : this.maxHandleElement.position - position;
  2046. this.onStart(pointerType, event, bindMove, bindEnd);
  2047. };
  2048. SliderComponent.prototype.getMinValue = function (newPos, outOfBounds, isAbove) {
  2049. var isRTL = this.viewOptions.rightToLeft;
  2050. var value = null;
  2051. if (outOfBounds) {
  2052. if (isAbove) {
  2053. value = isRTL
  2054. ? this.viewOptions.floor
  2055. : this.viewOptions.ceil - this.dragging.difference;
  2056. }
  2057. else {
  2058. value = isRTL
  2059. ? this.viewOptions.ceil - this.dragging.difference
  2060. : this.viewOptions.floor;
  2061. }
  2062. }
  2063. else {
  2064. value = isRTL
  2065. ? this.positionToValue(newPos + this.dragging.lowLimit)
  2066. : this.positionToValue(newPos - this.dragging.lowLimit);
  2067. }
  2068. return this.roundStep(value);
  2069. };
  2070. SliderComponent.prototype.getMaxValue = function (newPos, outOfBounds, isAbove) {
  2071. var isRTL = this.viewOptions.rightToLeft;
  2072. var value = null;
  2073. if (outOfBounds) {
  2074. if (isAbove) {
  2075. value = isRTL
  2076. ? this.viewOptions.floor + this.dragging.difference
  2077. : this.viewOptions.ceil;
  2078. }
  2079. else {
  2080. value = isRTL
  2081. ? this.viewOptions.ceil
  2082. : this.viewOptions.floor + this.dragging.difference;
  2083. }
  2084. }
  2085. else {
  2086. if (isRTL) {
  2087. value =
  2088. this.positionToValue(newPos + this.dragging.lowLimit) +
  2089. this.dragging.difference;
  2090. }
  2091. else {
  2092. value =
  2093. this.positionToValue(newPos - this.dragging.lowLimit) +
  2094. this.dragging.difference;
  2095. }
  2096. }
  2097. return this.roundStep(value);
  2098. };
  2099. SliderComponent.prototype.onDragMove = function (event) {
  2100. var newPos = this.getEventPosition(event);
  2101. var ceilLimit, floorLimit, floorHandleElement, ceilHandleElement;
  2102. if (this.viewOptions.rightToLeft) {
  2103. ceilLimit = this.dragging.lowLimit;
  2104. floorLimit = this.dragging.highLimit;
  2105. floorHandleElement = this.maxHandleElement;
  2106. ceilHandleElement = this.minHandleElement;
  2107. }
  2108. else {
  2109. ceilLimit = this.dragging.highLimit;
  2110. floorLimit = this.dragging.lowLimit;
  2111. floorHandleElement = this.minHandleElement;
  2112. ceilHandleElement = this.maxHandleElement;
  2113. }
  2114. var isUnderFloorLimit = (newPos <= floorLimit);
  2115. var isOverCeilLimit = (newPos >= this.maxHandlePosition - ceilLimit);
  2116. var newMinValue;
  2117. var newMaxValue;
  2118. if (isUnderFloorLimit) {
  2119. if (floorHandleElement.position === 0) {
  2120. return;
  2121. }
  2122. newMinValue = this.getMinValue(newPos, true, false);
  2123. newMaxValue = this.getMaxValue(newPos, true, false);
  2124. }
  2125. else if (isOverCeilLimit) {
  2126. if (ceilHandleElement.position === this.maxHandlePosition) {
  2127. return;
  2128. }
  2129. newMaxValue = this.getMaxValue(newPos, true, true);
  2130. newMinValue = this.getMinValue(newPos, true, true);
  2131. }
  2132. else {
  2133. newMinValue = this.getMinValue(newPos, false, false);
  2134. newMaxValue = this.getMaxValue(newPos, false, false);
  2135. }
  2136. this.positionTrackingBar(newMinValue, newMaxValue);
  2137. };
  2138. SliderComponent.prototype.positionTrackingBar = function (newMinValue, newMaxValue) {
  2139. if (!ValueHelper.isNullOrUndefined(this.viewOptions.minLimit) &&
  2140. newMinValue < this.viewOptions.minLimit) {
  2141. newMinValue = this.viewOptions.minLimit;
  2142. newMaxValue = MathHelper.roundToPrecisionLimit(newMinValue + this.dragging.difference, this.viewOptions.precisionLimit);
  2143. }
  2144. if (!ValueHelper.isNullOrUndefined(this.viewOptions.maxLimit) &&
  2145. newMaxValue > this.viewOptions.maxLimit) {
  2146. newMaxValue = this.viewOptions.maxLimit;
  2147. newMinValue = MathHelper.roundToPrecisionLimit(newMaxValue - this.dragging.difference, this.viewOptions.precisionLimit);
  2148. }
  2149. this.viewLowValue = newMinValue;
  2150. this.viewHighValue = newMaxValue;
  2151. this.applyViewChange();
  2152. this.updateHandles(PointerType.Min, this.valueToPosition(newMinValue));
  2153. this.updateHandles(PointerType.Max, this.valueToPosition(newMaxValue));
  2154. };
  2155. SliderComponent.prototype.positionTrackingHandle = function (newValue) {
  2156. newValue = this.applyMinMaxLimit(newValue);
  2157. if (this.range) {
  2158. if (this.viewOptions.pushRange) {
  2159. newValue = this.applyPushRange(newValue);
  2160. }
  2161. else {
  2162. if (this.viewOptions.noSwitching) {
  2163. if (this.currentTrackingPointer === PointerType.Min &&
  2164. newValue > this.viewHighValue) {
  2165. newValue = this.applyMinMaxRange(this.viewHighValue);
  2166. }
  2167. else if (this.currentTrackingPointer === PointerType.Max &&
  2168. newValue < this.viewLowValue) {
  2169. newValue = this.applyMinMaxRange(this.viewLowValue);
  2170. }
  2171. }
  2172. newValue = this.applyMinMaxRange(newValue);
  2173. if (this.currentTrackingPointer === PointerType.Min && newValue > this.viewHighValue) {
  2174. this.viewLowValue = this.viewHighValue;
  2175. this.applyViewChange();
  2176. this.updateHandles(PointerType.Min, this.maxHandleElement.position);
  2177. this.updateAriaAttributes();
  2178. this.currentTrackingPointer = PointerType.Max;
  2179. this.minHandleElement.active = false;
  2180. this.maxHandleElement.active = true;
  2181. if (this.viewOptions.keyboardSupport) {
  2182. this.maxHandleElement.focus();
  2183. }
  2184. }
  2185. else if (this.currentTrackingPointer === PointerType.Max &&
  2186. newValue < this.viewLowValue) {
  2187. this.viewHighValue = this.viewLowValue;
  2188. this.applyViewChange();
  2189. this.updateHandles(PointerType.Max, this.minHandleElement.position);
  2190. this.updateAriaAttributes();
  2191. this.currentTrackingPointer = PointerType.Min;
  2192. this.maxHandleElement.active = false;
  2193. this.minHandleElement.active = true;
  2194. if (this.viewOptions.keyboardSupport) {
  2195. this.minHandleElement.focus();
  2196. }
  2197. }
  2198. }
  2199. }
  2200. if (this.getCurrentTrackingValue() !== newValue) {
  2201. if (this.currentTrackingPointer === PointerType.Min) {
  2202. this.viewLowValue = newValue;
  2203. this.applyViewChange();
  2204. }
  2205. else if (this.currentTrackingPointer === PointerType.Max) {
  2206. this.viewHighValue = newValue;
  2207. this.applyViewChange();
  2208. }
  2209. this.updateHandles(this.currentTrackingPointer, this.valueToPosition(newValue));
  2210. this.updateAriaAttributes();
  2211. }
  2212. };
  2213. SliderComponent.prototype.applyMinMaxLimit = function (newValue) {
  2214. if (!ValueHelper.isNullOrUndefined(this.viewOptions.minLimit) && newValue < this.viewOptions.minLimit) {
  2215. return this.viewOptions.minLimit;
  2216. }
  2217. if (!ValueHelper.isNullOrUndefined(this.viewOptions.maxLimit) && newValue > this.viewOptions.maxLimit) {
  2218. return this.viewOptions.maxLimit;
  2219. }
  2220. return newValue;
  2221. };
  2222. SliderComponent.prototype.applyMinMaxRange = function (newValue) {
  2223. var oppositeValue = (this.currentTrackingPointer === PointerType.Min)
  2224. ? this.viewHighValue
  2225. : this.viewLowValue;
  2226. var difference = Math.abs(newValue - oppositeValue);
  2227. if (!ValueHelper.isNullOrUndefined(this.viewOptions.minRange)) {
  2228. if (difference < this.viewOptions.minRange) {
  2229. if (this.currentTrackingPointer === PointerType.Min) {
  2230. return MathHelper.roundToPrecisionLimit(this.viewHighValue - this.viewOptions.minRange, this.viewOptions.precisionLimit);
  2231. }
  2232. else if (this.currentTrackingPointer === PointerType.Max) {
  2233. return MathHelper.roundToPrecisionLimit(this.viewLowValue + this.viewOptions.minRange, this.viewOptions.precisionLimit);
  2234. }
  2235. }
  2236. }
  2237. if (!ValueHelper.isNullOrUndefined(this.viewOptions.maxRange)) {
  2238. if (difference > this.viewOptions.maxRange) {
  2239. if (this.currentTrackingPointer === PointerType.Min) {
  2240. return MathHelper.roundToPrecisionLimit(this.viewHighValue - this.viewOptions.maxRange, this.viewOptions.precisionLimit);
  2241. }
  2242. else if (this.currentTrackingPointer === PointerType.Max) {
  2243. return MathHelper.roundToPrecisionLimit(this.viewLowValue + this.viewOptions.maxRange, this.viewOptions.precisionLimit);
  2244. }
  2245. }
  2246. }
  2247. return newValue;
  2248. };
  2249. SliderComponent.prototype.applyPushRange = function (newValue) {
  2250. var difference = (this.currentTrackingPointer === PointerType.Min)
  2251. ? this.viewHighValue - newValue
  2252. : newValue - this.viewLowValue;
  2253. var minRange = (!ValueHelper.isNullOrUndefined(this.viewOptions.minRange))
  2254. ? this.viewOptions.minRange
  2255. : this.viewOptions.step;
  2256. var maxRange = this.viewOptions.maxRange;
  2257. if (difference < minRange) {
  2258. if (this.currentTrackingPointer === PointerType.Min) {
  2259. this.viewHighValue = MathHelper.roundToPrecisionLimit(Math.min(newValue + minRange, this.viewOptions.ceil), this.viewOptions.precisionLimit);
  2260. newValue = MathHelper.roundToPrecisionLimit(this.viewHighValue - minRange, this.viewOptions.precisionLimit);
  2261. this.applyViewChange();
  2262. this.updateHandles(PointerType.Max, this.valueToPosition(this.viewHighValue));
  2263. }
  2264. else if (this.currentTrackingPointer === PointerType.Max) {
  2265. this.viewLowValue = MathHelper.roundToPrecisionLimit(Math.max(newValue - minRange, this.viewOptions.floor), this.viewOptions.precisionLimit);
  2266. newValue = MathHelper.roundToPrecisionLimit(this.viewLowValue + minRange, this.viewOptions.precisionLimit);
  2267. this.applyViewChange();
  2268. this.updateHandles(PointerType.Min, this.valueToPosition(this.viewLowValue));
  2269. }
  2270. this.updateAriaAttributes();
  2271. }
  2272. else if (!ValueHelper.isNullOrUndefined(maxRange) && difference > maxRange) {
  2273. if (this.currentTrackingPointer === PointerType.Min) {
  2274. this.viewHighValue = MathHelper.roundToPrecisionLimit(newValue + maxRange, this.viewOptions.precisionLimit);
  2275. this.applyViewChange();
  2276. this.updateHandles(PointerType.Max, this.valueToPosition(this.viewHighValue));
  2277. }
  2278. else if (this.currentTrackingPointer === PointerType.Max) {
  2279. this.viewLowValue = MathHelper.roundToPrecisionLimit(newValue - maxRange, this.viewOptions.precisionLimit);
  2280. this.applyViewChange();
  2281. this.updateHandles(PointerType.Min, this.valueToPosition(this.viewLowValue));
  2282. }
  2283. this.updateAriaAttributes();
  2284. }
  2285. return newValue;
  2286. };
  2287. SliderComponent.prototype.getChangeContext = function () {
  2288. var changeContext = new ChangeContext();
  2289. changeContext.pointerType = this.currentTrackingPointer;
  2290. changeContext.value = +this.value;
  2291. if (this.range) {
  2292. changeContext.highValue = +this.highValue;
  2293. }
  2294. return changeContext;
  2295. };
  2296. return SliderComponent;
  2297. }());
  2298. SliderComponent.decorators = [
  2299. { type: core.Component, args: [{
  2300. selector: 'ng5-slider',
  2301. template: "<!-- // 0 Left selection bar outside two handles -->\n<span ng5SliderElement #leftOuterSelectionBar class=\"ng5-slider-span ng5-slider-bar-wrapper ng5-slider-left-out-selection\">\n <span class=\"ng5-slider-span ng5-slider-bar\"></span>\n</span>\n<!-- // 1 Right selection bar outside two handles -->\n<span ng5SliderElement #rightOuterSelectionBar class=\"ng5-slider-span ng5-slider-bar-wrapper ng5-slider-right-out-selection\">\n <span class=\"ng5-slider-span ng5-slider-bar\"></span>\n</span>\n<!-- // 2 The whole slider bar -->\n<span ng5SliderElement #fullBar [class.ng5-slider-transparent]=\"fullBarTransparentClass\" class=\"ng5-slider-span ng5-slider-bar-wrapper ng5-slider-full-bar\">\n <span class=\"ng5-slider-span ng5-slider-bar\"></span>\n</span>\n<!-- // 3 Selection bar between two handles -->\n<span ng5SliderElement #selectionBar [class.ng5-slider-draggable]=\"selectionBarDraggableClass\" class=\"ng5-slider-span ng5-slider-bar-wrapper ng5-slider-selection-bar\">\n <span class=\"ng5-slider-span ng5-slider-bar ng5-slider-selection\" [ngStyle]=\"barStyle\"></span>\n</span>\n<!-- // 4 Low slider handle -->\n<span ng5SliderHandle #minHandle class=\"ng5-slider-span ng5-slider-pointer ng5-slider-pointer-min\" [ngStyle]=minPointerStyle></span>\n<!-- // 5 High slider handle -->\n<span ng5SliderHandle #maxHandle [style.display]=\"range ? 'inherit' : 'none'\" class=\"ng5-slider-span ng5-slider-pointer ng5-slider-pointer-max\" [ngStyle]=maxPointerStyle></span>\n<!-- // 6 Floor label -->\n<span ng5SliderLabel #floorLabel class=\"ng5-slider-span ng5-slider-bubble ng5-slider-limit ng5-slider-floor\"></span>\n<!-- // 7 Ceiling label -->\n<span ng5SliderLabel #ceilLabel class=\"ng5-slider-span ng5-slider-bubble ng5-slider-limit ng5-slider-ceil\"></span>\n<!-- // 8 Label above the low slider handle -->\n<span ng5SliderLabel #minHandleLabel class=\"ng5-slider-span ng5-slider-bubble ng5-slider-model-value\"></span>\n<!-- // 9 Label above the high slider handle -->\n<span ng5SliderLabel #maxHandleLabel class=\"ng5-slider-span ng5-slider-bubble ng5-slider-model-high\"></span>\n<!-- // 10 Combined range label when the slider handles are close ex. 15 - 17 -->\n<span ng5SliderLabel #combinedLabel class=\"ng5-slider-span ng5-slider-bubble ng5-slider-combined\"></span>\n<!-- // 11 The ticks -->\n<span ng5SliderElement #ticksElement [hidden]=\"!showTicks\" [class.ng5-slider-ticks-values-under]=\"ticksUnderValuesClass\" class=\"ng5-slider-ticks\">\n <span *ngFor=\"let t of ticks\" class=\"ng5-slider-tick\" [ngClass]=\"{'ng5-slider-selected': t.selected}\" [ngStyle]=\"t.style\">\n <ng5-slider-tooltip-wrapper [template]=\"tooltipTemplate\" [tooltip]=\"t.tooltip\" [placement]=\"t.tooltipPlacement\"></ng5-slider-tooltip-wrapper>\n <ng5-slider-tooltip-wrapper *ngIf=\"t.value != null\" class=\"ng5-slider-span ng5-slider-tick-value\"\n [template]=\"tooltipTemplate\" [tooltip]=\"t.valueTooltip\" [placement]=\"t.valueTooltipPlacement\" [content]=\"t.value\"></ng5-slider-tooltip-wrapper>\n <span *ngIf=\"t.legend != null\" class=\"ng5-slider-span ng5-slider-tick-legend\" [innerHTML]=\"t.legend\"></span>\n </span>\n</span>",
  2302. styles: ["::ng-deep .ng5-slider{display:inline-block;position:relative;height:4px;width:100%;margin:35px 0 15px;vertical-align:middle;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-ms-touch-action:pan-y;touch-action:pan-y}::ng-deep .ng5-slider.with-legend{margin-bottom:40px}::ng-deep .ng5-slider[disabled]{cursor:not-allowed}::ng-deep .ng5-slider[disabled] .ng5-slider-pointer{cursor:not-allowed;background-color:#d8e0f3}::ng-deep .ng5-slider[disabled] .ng5-slider-draggable{cursor:not-allowed}::ng-deep .ng5-slider[disabled] .ng5-slider-selection{background:#8b91a2}::ng-deep .ng5-slider[disabled] .ng5-slider-tick{cursor:not-allowed}::ng-deep .ng5-slider[disabled] .ng5-slider-tick.ng5-slider-selected{background:#8b91a2}::ng-deep .ng5-slider .ng5-slider-span{white-space:nowrap;position:absolute;display:inline-block}::ng-deep .ng5-slider .ng5-slider-base{width:100%;height:100%;padding:0}::ng-deep .ng5-slider .ng5-slider-bar-wrapper{left:0;-webkit-box-sizing:border-box;box-sizing:border-box;margin-top:-16px;padding-top:16px;width:100%;height:32px;z-index:1}::ng-deep .ng5-slider .ng5-slider-draggable{cursor:move}::ng-deep .ng5-slider .ng5-slider-bar{left:0;width:100%;height:4px;z-index:1;background:#d8e0f3;border-radius:2px}::ng-deep .ng5-slider .ng5-slider-bar-wrapper.ng5-slider-transparent .ng5-slider-bar{background:0 0}::ng-deep .ng5-slider .ng5-slider-bar-wrapper.ng5-slider-left-out-selection .ng5-slider-bar{background:#df002d}::ng-deep .ng5-slider .ng5-slider-bar-wrapper.ng5-slider-right-out-selection .ng5-slider-bar{background:#03a688}::ng-deep .ng5-slider .ng5-slider-selection{z-index:2;background:#0db9f0;border-radius:2px}::ng-deep .ng5-slider .ng5-slider-pointer{cursor:pointer;width:32px;height:32px;top:-14px;background-color:#0db9f0;z-index:3;border-radius:16px}::ng-deep .ng5-slider .ng5-slider-pointer:after{content:'';width:8px;height:8px;position:absolute;top:12px;left:12px;border-radius:4px;background:#fff}::ng-deep .ng5-slider .ng5-slider-pointer:hover:after{background-color:#fff}::ng-deep .ng5-slider .ng5-slider-pointer.ng5-slider-active{z-index:4}::ng-deep .ng5-slider .ng5-slider-pointer.ng5-slider-active:after{background-color:#451aff}::ng-deep .ng5-slider .ng5-slider-bubble{cursor:default;bottom:16px;padding:1px 3px;color:#55637d;font-size:16px}::ng-deep .ng5-slider .ng5-slider-bubble.ng5-slider-limit{color:#55637d}::ng-deep .ng5-slider .ng5-slider-ticks{-webkit-box-sizing:border-box;box-sizing:border-box;width:100%;height:0;position:absolute;left:0;top:-3px;margin:0;z-index:1;list-style:none}::ng-deep .ng5-slider .ng5-slider-ticks-values-under .ng5-slider-tick-value{top:auto;bottom:-36px}::ng-deep .ng5-slider .ng5-slider-tick{text-align:center;cursor:pointer;width:10px;height:10px;background:#d8e0f3;border-radius:50%;position:absolute;top:0;left:0;margin-left:11px}::ng-deep .ng5-slider .ng5-slider-tick.ng5-slider-selected{background:#0db9f0}::ng-deep .ng5-slider .ng5-slider-tick-value{position:absolute;top:-34px;-webkit-transform:translate(-50%,0);transform:translate(-50%,0)}::ng-deep .ng5-slider .ng5-slider-tick-legend{position:absolute;top:24px;-webkit-transform:translate(-50%,0);transform:translate(-50%,0);max-width:50px;white-space:normal}::ng-deep .ng5-slider.vertical{position:relative;width:4px;height:100%;margin:0 20px;padding:0;vertical-align:baseline;-ms-touch-action:pan-x;touch-action:pan-x}::ng-deep .ng5-slider.vertical .ng5-slider-base{width:100%;height:100%;padding:0}::ng-deep .ng5-slider.vertical .ng5-slider-bar-wrapper{top:auto;left:0;margin:0 0 0 -16px;padding:0 0 0 16px;height:100%;width:32px}::ng-deep .ng5-slider.vertical .ng5-slider-bar{bottom:0;left:auto;width:4px;height:100%}::ng-deep .ng5-slider.vertical .ng5-slider-pointer{left:-14px!important;top:auto;bottom:0}::ng-deep .ng5-slider.vertical .ng5-slider-bubble{left:16px!important;bottom:0}::ng-deep .ng5-slider.vertical .ng5-slider-ticks{height:100%;width:0;left:-3px;top:0;z-index:1}::ng-deep .ng5-slider.vertical .ng5-slider-tick{vertical-align:middle;margin-left:auto;margin-top:11px}::ng-deep .ng5-slider.vertical .ng5-slider-tick-value{left:24px;top:auto;-webkit-transform:translate(0,-28%);transform:translate(0,-28%)}::ng-deep .ng5-slider.vertical .ng5-slider-tick-legend{top:auto;right:24px;-webkit-transform:translate(0,-28%);transform:translate(0,-28%);max-width:none;white-space:nowrap}::ng-deep .ng5-slider.vertical .ng5-slider-ticks-values-under .ng5-slider-tick-value{bottom:auto;left:auto;right:24px}::ng-deep .ng5-slider *{-webkit-transition:none;transition:none}::ng-deep .ng5-slider.animate .ng5-slider-bar-wrapper{-webkit-transition:all linear .3s;transition:all linear .3s}::ng-deep .ng5-slider.animate .ng5-slider-selection{-webkit-transition:background-color linear .3s;transition:background-color linear .3s}::ng-deep .ng5-slider.animate .ng5-slider-pointer{-webkit-transition:all linear .3s;transition:all linear .3s}::ng-deep .ng5-slider.animate .ng5-slider-bubble{-webkit-transition:all linear .3s;transition:all linear .3s}::ng-deep .ng5-slider.animate .ng5-slider-bubble.ng5-slider-limit{-webkit-transition:opacity linear .3s;transition:opacity linear .3s}::ng-deep .ng5-slider.animate .ng5-slider-bubble.ng5-slider-combined{-webkit-transition:opacity linear .3s;transition:opacity linear .3s}::ng-deep .ng5-slider.animate .ng5-slider-tick{-webkit-transition:background-color linear .3s;transition:background-color linear .3s}"],
  2303. host: { class: 'ng5-slider' },
  2304. providers: [NG5_SLIDER_CONTROL_VALUE_ACCESSOR]
  2305. },] },
  2306. ];
  2307. SliderComponent.ctorParameters = function () { return [
  2308. { type: core.Renderer2, },
  2309. { type: core.ElementRef, },
  2310. { type: core.ChangeDetectorRef, },
  2311. { type: core.NgZone, },
  2312. ]; };
  2313. SliderComponent.propDecorators = {
  2314. "value": [{ type: core.Input },],
  2315. "valueChange": [{ type: core.Output },],
  2316. "highValue": [{ type: core.Input },],
  2317. "highValueChange": [{ type: core.Output },],
  2318. "options": [{ type: core.Input },],
  2319. "userChangeStart": [{ type: core.Output },],
  2320. "userChange": [{ type: core.Output },],
  2321. "userChangeEnd": [{ type: core.Output },],
  2322. "manualRefresh": [{ type: core.Input },],
  2323. "triggerFocus": [{ type: core.Input },],
  2324. "leftOuterSelectionBarElement": [{ type: core.ViewChild, args: ['leftOuterSelectionBar', { read: SliderElementDirective },] },],
  2325. "rightOuterSelectionBarElement": [{ type: core.ViewChild, args: ['rightOuterSelectionBar', { read: SliderElementDirective },] },],
  2326. "fullBarElement": [{ type: core.ViewChild, args: ['fullBar', { read: SliderElementDirective },] },],
  2327. "selectionBarElement": [{ type: core.ViewChild, args: ['selectionBar', { read: SliderElementDirective },] },],
  2328. "minHandleElement": [{ type: core.ViewChild, args: ['minHandle', { read: SliderHandleDirective },] },],
  2329. "maxHandleElement": [{ type: core.ViewChild, args: ['maxHandle', { read: SliderHandleDirective },] },],
  2330. "floorLabelElement": [{ type: core.ViewChild, args: ['floorLabel', { read: SliderLabelDirective },] },],
  2331. "ceilLabelElement": [{ type: core.ViewChild, args: ['ceilLabel', { read: SliderLabelDirective },] },],
  2332. "minHandleLabelElement": [{ type: core.ViewChild, args: ['minHandleLabel', { read: SliderLabelDirective },] },],
  2333. "maxHandleLabelElement": [{ type: core.ViewChild, args: ['maxHandleLabel', { read: SliderLabelDirective },] },],
  2334. "combinedLabelElement": [{ type: core.ViewChild, args: ['combinedLabel', { read: SliderLabelDirective },] },],
  2335. "ticksElement": [{ type: core.ViewChild, args: ['ticksElement', { read: SliderElementDirective },] },],
  2336. "tooltipTemplate": [{ type: core.ContentChild, args: ['tooltipTemplate',] },],
  2337. "sliderElementVerticalClass": [{ type: core.HostBinding, args: ['class.vertical',] },],
  2338. "sliderElementAnimateClass": [{ type: core.HostBinding, args: ['class.animate',] },],
  2339. "sliderElementDisabledAttr": [{ type: core.HostBinding, args: ['attr.disabled',] },],
  2340. "onResize": [{ type: core.HostListener, args: ['window:resize', ['$event'],] },],
  2341. };
  2342. var TooltipWrapperComponent = /** @class */ (function () {
  2343. function TooltipWrapperComponent() {
  2344. }
  2345. return TooltipWrapperComponent;
  2346. }());
  2347. TooltipWrapperComponent.decorators = [
  2348. { type: core.Component, args: [{
  2349. selector: 'ng5-slider-tooltip-wrapper',
  2350. template: "<ng-container *ngIf=\"template\">\n <ng-template *ngTemplateOutlet=\"template; context: {tooltip: tooltip, placement: placement, content: content}\"></ng-template>\n</ng-container>\n\n<ng-container *ngIf=\"!template\">\n <div class=\"ng5-slider-inner-tooltip\" [attr.title]=\"tooltip\" [attr.data-tooltip-placement]=\"placement\">\n {{content}}\n </div>\n</ng-container>",
  2351. styles: [".ng5-slider-inner-tooltip{height:100%}"]
  2352. },] },
  2353. ];
  2354. TooltipWrapperComponent.ctorParameters = function () { return []; };
  2355. TooltipWrapperComponent.propDecorators = {
  2356. "template": [{ type: core.Input },],
  2357. "tooltip": [{ type: core.Input },],
  2358. "placement": [{ type: core.Input },],
  2359. "content": [{ type: core.Input },],
  2360. };
  2361. var Ng5SliderModule = /** @class */ (function () {
  2362. function Ng5SliderModule() {
  2363. }
  2364. return Ng5SliderModule;
  2365. }());
  2366. Ng5SliderModule.decorators = [
  2367. { type: core.NgModule, args: [{
  2368. imports: [
  2369. common.CommonModule
  2370. ],
  2371. declarations: [
  2372. SliderComponent,
  2373. SliderElementDirective,
  2374. SliderHandleDirective,
  2375. SliderLabelDirective,
  2376. TooltipWrapperComponent
  2377. ],
  2378. exports: [
  2379. SliderComponent
  2380. ]
  2381. },] },
  2382. ];
  2383. Ng5SliderModule.ctorParameters = function () { return []; };
  2384. exports.Ng5SliderModule = Ng5SliderModule;
  2385. exports.ChangeContext = ChangeContext;
  2386. exports.PointerType = PointerType;
  2387. exports.LabelType = LabelType;
  2388. exports.Options = Options;
  2389. exports.ɵb = SliderElementDirective;
  2390. exports.ɵc = SliderHandleDirective;
  2391. exports.ɵd = SliderLabelDirective;
  2392. exports.ɵa = SliderComponent;
  2393. exports.ɵe = TooltipWrapperComponent;
  2394. Object.defineProperty(exports, '__esModule', { value: true });
  2395. })));
  2396. //# sourceMappingURL=ng5-slider.umd.js.map