darul75 / angular-awesome-slider

:arrows_clockwise: Angular slider control directive
http://darul75.github.io/angular-awesome-slider/
MIT License
144 stars 63 forks source link

Can we display a label for slider with steps? #75

Open praswebdev opened 9 years ago

praswebdev commented 9 years ago

Hi, Can we display a label for the slider with steps, which moves with the pointer? Right now i can see the the values 0, 1, 2, etc displayed for step labels. Instead can i display the scale value test1, test2,test3 etc.. $scope.singleoptions = { from: 0, to: 4, step: 1, dimension: " ", scale: ['test1', 'test2', 'test3', 'test4', 'test5'] }; http://jsfiddle.net/g9e9n8xc/67/

darul75 commented 9 years ago

good idea, I see what I can do with dimension string, maybe with a specific character to handle prefix or suffix.

olegakbarov commented 9 years ago

That would be really useful, i've stumbled upon the need of it.

darul75 commented 9 years ago

need time but ok I will stop what I was doing to implement it first ;)

olegakbarov commented 9 years ago

i'm actually WIP with this stuff and came up with this monkey-patch:

At first i added an array of label values to options object

var OPTIONS = {
...
discreteValues: ["value1", "value2", "value3"]
...
}

than in directive i've rewritten the defaults

var OPTIONS = {
from: 0,
to: scope.options.discreteValues.length - 1
...
discreteValues: scope.options.discreteValues
}

and finally just set the value to map to corresponding string in discreteValues array

this.o.labels[pointer.uid].value.html(
this.settings.discreteValues[this.nice(pointer.value.origin)]
);

let me know what you do think i can send a PR if you think this is fine solution

darul75 commented 9 years ago

dimension is given ability to set suffix string, would a prefix string enough for you ?

dimension "km" : will display "1 km", "2 km", "3 km"... dimension ">> km " : will display "km 1", "km 2", "km 3"...

I was thinking about that.

You all mean labels on pointers ? we change nothing to scale labels ? ;)

darul75 commented 9 years ago

hmm or just display scale value for pointer when pointers on it ?

olegakbarov commented 9 years ago

Thanks for reply!

Suffix string would not be option for me. I need to display strings without numbers :/ I need a value that works like dropdown:

sld

I think binding a model to pointer value would be useful case.

darul75 commented 9 years ago

ok, maybe still not closed enough to what you mean but can you check this one:

http://jsfiddle.net/darul75/3kt5mv8w/1/

value binding is set in options with json obj "keyModel:valueLabel"

modelLabels: {1: 'WTF', 2: 'OK'},`

bit it is display on top of pointers ?

olegakbarov commented 9 years ago

Yeah, this fiddle looks like what i need! So the question is how to attach modelLabels to the top fo pointer?

darul75 commented 9 years ago

to the bottom you mean ? ;)

olegakbarov commented 9 years ago

Hahaha, yeah! I guess i need one more cup of coffee.

darul75 commented 9 years ago

I have to go now but check that asap