Closed kanagukrs closed 9 years ago
Looks like a good idea, with your example with a range of 0 -> 100
it will give something like
-----LOW-----MEDIUM-----HIGH-------------------------------------------------------------------------------------
?
I have changed generateScale, valueToPrc, and limits functions a little bit to accept the mentioned scale value, soon I will commit the change or will give a PR to you, it may be useful to implement this enhancement
ok do not hesitate, take your time and pls check it is fine for both vertical, horizontal slider
As I don't have permission to do a push, I am posting the changes here File : slider.factory.js @ generateScale line 276 - 285
var str = "",
s = this.settings.scale,
// FIX Big Scale Failure #34
// var prc = Math.round((100/(s.length-1))*10)/10;
prc,
label,
duplicate = {},
position = this.settings.vertical ? 'top' : 'left',
i=0;
for(; i < s.length; i++) {
if (s[i].val <= this.settings.to && s[i].val >= this.settings.from && ! duplicate[s[i].val]) {
duplicate[s[i].val] = true;
prc = this.valueToPrc(s[i].val);
label = s[i].label ? s[i].label : s[i].val;
str += '<span style="'+ position + ': ' + prc + '%">' + '<ins>' + label + '</ins>' + '</span>';
}
}
@ valueToPrc line 611
if (pointer) {
prc = pointer.limits(_start + (value-_from)*(v[0]-_start)/(v[1]-_from));
} else {
prc = this.limits(_start + (value-_from)*(v[0]-_start)/(v[1]-_from));
}
@ valueToPrc line 618
if (pointer) {
prc = pointer.limits((value-this.settings.from)*100/this.settings.interval);
} else {
prc = this.limits((value-this.settings.from)*100/this.settings.interval);
}
@ limits line 259-263
if (pointer) {
var another = this.o.pointers[1-pointer.uid];
if(another && pointer.uid && x < another.value.prc) x = another.value.prc;
if(another && !pointer.uid && x > another.value.prc) x = another.value.prc;
}
These are the changes we did to implement custom label for scale option
You can not push directly but pull requests are always welcome. First thank you for your work as I know how it has been difficult maybe ;) I check it asap and come back to you. Julien
Created a PR... https://github.com/darul75/ng-slider/pull/90
Shall I close this issue as you merged the fix
Yes sure but I got no time to check it really to provide a release then. Thx
Ok, I have expected a release, but in order to finish my work, I just cloned your slider and updated in awesome-range-slider. You can take a look. If you are ok, I will do a pull request for the issue Change the "ng" prefix to something else
I am just too busy on side projects but it is coming @kanaguks
Yes, I agree, if you are going for a release, you need to update document and demo as well
As I give scale values in array, it takes the array length for positioning, and array values as label. It may be an issue or enhancement, we need to give value and custom label in the array as an object, and we may use that value for positioning the label
Ex:- SCALE - [{val:5, label:"low"}, {val:10, label:"medium"}, {val:15, label:"high"}]