|
1 | 1 | /*! angularjs-slider - v2.5.0 -
|
2 | 2 | (c) Rafal Zajac <[email protected]>, Valentin Hervieu <[email protected]>, Jussi Saarivirta <[email protected]>, Angelin Sirbu <[email protected]> -
|
3 | 3 | https://github.com/angular-slider/angularjs-slider -
|
4 |
| - 2016-01-24 */ |
| 4 | + 2016-01-31 */ |
5 | 5 | /*jslint unparam: true */
|
6 | 6 | /*global angular: false, console: false, define, module */
|
7 | 7 | (function(root, factory) {
|
|
631 | 631 | this.step = +this.options.step;
|
632 | 632 | this.precision = +this.options.precision;
|
633 | 633 |
|
| 634 | + this.minValue = this.options.floor; |
| 635 | + |
634 | 636 | this.scope.rzSliderModel = this.roundStep(this.scope.rzSliderModel);
|
635 | 637 | if (this.range)
|
636 | 638 | this.scope.rzSliderHigh = this.roundStep(this.scope.rzSliderHigh);
|
637 | 639 |
|
638 |
| - this.minValue = this.roundStep(+this.options.floor); |
639 |
| - |
640 | 640 | if (this.options.ceil != null)
|
641 |
| - this.maxValue = this.roundStep(+this.options.ceil); |
| 641 | + this.maxValue = this.options.ceil; |
642 | 642 | else
|
643 | 643 | this.maxValue = this.options.ceil = this.range ? this.scope.rzSliderHigh : this.scope.rzSliderModel;
|
644 | 644 |
|
|
798 | 798 | callOnStart: function() {
|
799 | 799 | if (this.options.onStart) {
|
800 | 800 | var self = this;
|
801 |
| - this.scope.$evalAsync(function () { |
| 801 | + this.scope.$evalAsync(function() { |
802 | 802 | self.options.onStart(self.options.id, self.scope.rzSliderModel, self.scope.rzSliderHigh);
|
803 | 803 | });
|
804 | 804 | }
|
|
813 | 813 | callOnChange: function() {
|
814 | 814 | if (this.options.onChange) {
|
815 | 815 | var self = this;
|
816 |
| - this.scope.$evalAsync(function () { |
| 816 | + this.scope.$evalAsync(function() { |
817 | 817 | self.options.onChange(self.options.id, self.scope.rzSliderModel, self.scope.rzSliderHigh);
|
818 | 818 | });
|
819 | 819 | }
|
|
828 | 828 | callOnEnd: function() {
|
829 | 829 | if (this.options.onEnd) {
|
830 | 830 | var self = this;
|
831 |
| - this.scope.$evalAsync(function () { |
| 831 | + this.scope.$evalAsync(function() { |
832 | 832 | self.options.onEnd(self.options.id, self.scope.rzSliderModel, self.scope.rzSliderHigh);
|
833 | 833 | });
|
834 | 834 | }
|
|
993 | 993 | },
|
994 | 994 |
|
995 | 995 | /**
|
996 |
| - * Round value to step and precision |
| 996 | + * Round value to step and precision based on minValue |
997 | 997 | *
|
998 | 998 | * @param {number} value
|
999 | 999 | * @returns {number}
|
1000 | 1000 | */
|
1001 | 1001 | roundStep: function(value) {
|
1002 |
| - var steppedValue = parseFloat(value / this.step).toPrecision(12) |
1003 |
| - steppedValue = Math.round(steppedValue) * this.step; |
1004 |
| - steppedValue = steppedValue.toFixed(this.precision); |
1005 |
| - return +steppedValue; |
| 1002 | + var steppedDifference = parseFloat((value - this.minValue) / this.step).toPrecision(12); |
| 1003 | + steppedDifference = Math.round(+steppedDifference) * this.step; |
| 1004 | + var newValue = (this.minValue + (+steppedDifference)).toFixed(this.precision); |
| 1005 | + return +newValue; |
1006 | 1006 | },
|
1007 | 1007 |
|
1008 | 1008 | /**
|
|
0 commit comments