|
1 | 1 | // Ion.RangeSlider
|
2 |
| -// version 2.0.9 Build: 321 |
| 2 | +// version 2.0.10 Build: 323 |
3 | 3 | // © Denis Ineshin, 2015
|
4 | 4 | // https://github.com/IonDen
|
5 | 5 | //
|
|
138 | 138 | // Core
|
139 | 139 |
|
140 | 140 | var IonRangeSlider = function (input, options, plugin_count) {
|
141 |
| - this.VERSION = "2.0.9"; |
| 141 | + this.VERSION = "2.0.10"; |
142 | 142 | this.input = input;
|
143 | 143 | this.plugin_count = plugin_count;
|
144 | 144 | this.current_plugin = 0;
|
|
1288 | 1288 | calcReal: function (percent) {
|
1289 | 1289 | var min = this.options.min,
|
1290 | 1290 | max = this.options.max,
|
| 1291 | + min_decimals = min.toString().split(".")[1], |
| 1292 | + max_decimals = max.toString().split(".")[1], |
| 1293 | + min_length, max_length, |
| 1294 | + avg_decimals = 0, |
1291 | 1295 | abs = 0;
|
1292 | 1296 |
|
| 1297 | + if (min_decimals) { |
| 1298 | + min_length = min_decimals.length; |
| 1299 | + avg_decimals = min_length; |
| 1300 | + } |
| 1301 | + if (max_decimals) { |
| 1302 | + max_length = max_decimals.length; |
| 1303 | + avg_decimals = max_length; |
| 1304 | + } |
| 1305 | + if (min_length && max_length) { |
| 1306 | + avg_decimals = (min_length >= max_length) ? min_length : max_length; |
| 1307 | + } |
| 1308 | + |
1293 | 1309 | if (min < 0) {
|
1294 | 1310 | abs = Math.abs(min);
|
1295 |
| - min = min + abs; |
1296 |
| - max = max + abs; |
| 1311 | + min = +(min + abs).toFixed(avg_decimals); |
| 1312 | + max = +(max + abs).toFixed(avg_decimals); |
1297 | 1313 | }
|
1298 | 1314 |
|
1299 | 1315 | var number = ((max - min) / 100 * percent) + min,
|
1300 | 1316 | string = this.options.step.toString().split(".")[1],
|
1301 | 1317 | result;
|
1302 | 1318 |
|
1303 | 1319 | if (string) {
|
1304 |
| - number = +number.toFixed(string.length); |
| 1320 | + if (number !== min && number !== max) { |
| 1321 | + number = +number.toFixed(string.length); |
| 1322 | + } else { |
| 1323 | + number = +number.toFixed(avg_decimals); |
| 1324 | + } |
1305 | 1325 | } else {
|
1306 | 1326 | number = number / this.options.step;
|
1307 | 1327 | number = number * this.options.step;
|
|
1310 | 1330 |
|
1311 | 1331 | if (abs) {
|
1312 | 1332 | number -= abs;
|
| 1333 | + min = this.options.min; |
| 1334 | + max = this.options.max; |
1313 | 1335 | }
|
1314 | 1336 |
|
1315 | 1337 | if (string) {
|
1316 |
| - result = +number.toFixed(string.length); |
| 1338 | + if (number !== min && number !== max) { |
| 1339 | + result = +number.toFixed(string.length); |
| 1340 | + } else { |
| 1341 | + result = +number.toFixed(avg_decimals); |
| 1342 | + } |
1317 | 1343 | } else {
|
1318 | 1344 | result = this.toFixed(number);
|
1319 | 1345 | }
|
|
1709 | 1735 | local_small_max = small_max;
|
1710 | 1736 |
|
1711 | 1737 | big_w = this.toFixed(big_p * i);
|
| 1738 | + |
1712 | 1739 | if (big_w > 100) {
|
1713 | 1740 | big_w = 100;
|
1714 | 1741 |
|
|
0 commit comments