|
1 | 1 | /*! angularjs-slider - v2.6.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-31 */ |
| 4 | + 2016-02-03 */ |
5 | 5 | /*jslint unparam: true */
|
6 | 6 | /*global angular: false, console: false, define, module */
|
7 | 7 | (function(root, factory) {
|
|
39 | 39 | draggableRangeOnly: false,
|
40 | 40 | showSelectionBar: false,
|
41 | 41 | showSelectionBarEnd: false,
|
| 42 | + showSelectionBarFromValue: null, |
42 | 43 | hideLimitLabels: false,
|
43 | 44 | readOnly: false,
|
44 | 45 | disabled: false,
|
|
406 | 407 | this.options.showTicks = this.options.showTicks || this.options.showTicksValues;
|
407 | 408 | this.scope.showTicks = this.options.showTicks; //scope is used in the template
|
408 | 409 |
|
409 |
| - this.options.showSelectionBar = this.options.showSelectionBar || this.options.showSelectionBarEnd; |
| 410 | + this.options.showSelectionBar = this.options.showSelectionBar || this.options.showSelectionBarEnd |
| 411 | + || this.options.showSelectionBarFromValue !== null; |
410 | 412 |
|
411 | 413 | if (this.options.stepsArray) {
|
412 | 414 | this.options.floor = 0;
|
|
762 | 764 | },
|
763 | 765 |
|
764 | 766 | isTickSelected: function(value) {
|
765 |
| - if (!this.range && this.options.showSelectionBar && value <= this.scope.rzSliderModel) |
766 |
| - return true; |
| 767 | + if (!this.range) { |
| 768 | + if (this.options.showSelectionBarFromValue !== null) { |
| 769 | + var center = this.options.showSelectionBarFromValue; |
| 770 | + if (this.scope.rzSliderModel > center && value >= center && value <= this.scope.rzSliderModel) |
| 771 | + return true; |
| 772 | + else if (this.scope.rzSliderModel < center && value <= center && value >= this.scope.rzSliderModel) |
| 773 | + return true; |
| 774 | + } |
| 775 | + else if (this.options.showSelectionBarEnd) { |
| 776 | + if (value >= this.scope.rzSliderModel) |
| 777 | + return true; |
| 778 | + } |
| 779 | + else if (this.options.showSelectionBar && value <= this.scope.rzSliderModel) |
| 780 | + return true; |
| 781 | + } |
767 | 782 | if (this.range && value >= this.scope.rzSliderModel && value <= this.scope.rzSliderHigh)
|
768 | 783 | return true;
|
769 | 784 | return false;
|
|
932 | 947 | updateSelectionBar: function() {
|
933 | 948 | var position = 0,
|
934 | 949 | dimension = 0;
|
935 |
| - if (this.range || !this.options.showSelectionBarEnd) { |
936 |
| - dimension = Math.abs(this.maxH.rzsp - this.minH.rzsp) + this.handleHalfDim |
937 |
| - position = this.range ? this.minH.rzsp + this.handleHalfDim : 0; |
938 |
| - } else { |
939 |
| - dimension = Math.abs(this.maxPos - this.minH.rzsp) + this.handleHalfDim |
| 950 | + if(this.range) { |
| 951 | + dimension = Math.abs(this.maxH.rzsp - this.minH.rzsp) + this.handleHalfDim; |
940 | 952 | position = this.minH.rzsp + this.handleHalfDim;
|
941 | 953 | }
|
| 954 | + else { |
| 955 | + if (this.options.showSelectionBarFromValue !== null) { |
| 956 | + var center = this.options.showSelectionBarFromValue, |
| 957 | + centerPosition = this.valueToOffset(center); |
| 958 | + if (this.scope.rzSliderModel > center) { |
| 959 | + dimension = this.minH.rzsp - centerPosition; |
| 960 | + position = centerPosition + this.handleHalfDim; |
| 961 | + } |
| 962 | + else { |
| 963 | + dimension = centerPosition - this.minH.rzsp; |
| 964 | + position = this.minH.rzsp + this.handleHalfDim; |
| 965 | + } |
| 966 | + } |
| 967 | + else if (this.options.showSelectionBarEnd) { |
| 968 | + dimension = Math.abs(this.maxPos - this.minH.rzsp) + this.handleHalfDim; |
| 969 | + position = this.minH.rzsp + this.handleHalfDim; |
| 970 | + } else { |
| 971 | + dimension = Math.abs(this.maxH.rzsp - this.minH.rzsp) + this.handleHalfDim; |
| 972 | + position = 0; |
| 973 | + } |
| 974 | + } |
942 | 975 | this.setDimension(this.selBar, dimension);
|
943 | 976 | this.setPosition(this.selBar, position);
|
944 | 977 | if (this.options.getSelectionBarColor) {
|
|
0 commit comments