Skip to content

Question: How can create array of steps? #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rubinchyk opened this issue Jul 20, 2015 · 8 comments
Closed

Question: How can create array of steps? #85

rubinchyk opened this issue Jul 20, 2015 · 8 comments

Comments

@rubinchyk
Copy link

Hi.
Can you explain to me. How I can create an array of steps.
For example I have this code:
$scope.sensitivity = {
min: 10,
max: 50,
default: 10
};

I need fixed points like [10----20----50].
How can I do this?

@rubinchyk rubinchyk changed the title How can create array of steps? Question: How can create array of steps? Jul 21, 2015
@ValentinH
Copy link
Member

You can do this by using a custom translate function. The slider will be picking an index of your array and you will need to handle the link with the array.

<rzslider
    rz-slider-floor="yourSlider.floor"
    rz-slider-ceil="yourSlider.ceil"
    rz-slider-model="yourSlider.model"
    rz-slider-translate="translate"></rzslider>
var yourValues = [10, 25, 50, 80, 1000]; //obviously heterogeneous

$scope.yourSlider = {
    value: 0,
    floor: 0,
    ceil: yourValues.length - 1,
    step: 1
};

$scope.translate = function(index)
{
    if(index >= 0 && index < yourValues.length)
        return yourValues[index];
    return ''; //error case
};

then to get the selected value (you can set a watch to react on each change or use this #67 if it gets merged)

var selectedValue = yourValues[$scope.yourSlider.value];

@rubinchyk
Copy link
Author

Thank you

@dmolesworth
Copy link

dmolesworth commented May 12, 2016

How could I output a string value
stepsArray:'one,two,three'
Into an html <input>field similar to how the "Simple Slider" works?

@ValentinH
Copy link
Member

Sorry but I don't understand what you want...

@dmolesworth
Copy link

Sorry, I'll attempt to explain a different way...

Currently, the 'Simple Slider' displays its value in the 'Model:<input>' field as illustrated in this picture below
http://i.imgur.com/4hqBTWz.png

I want to create the same for the 'Alphabet Slider' where there is no 'Model:' box?

How would i do this?

@ValentinH
Copy link
Member

Hmm you can't do this since the value handled by the slider in this case is an index in an array, not the displayed value.

@dmolesworth
Copy link

Oh ok, thank you for your time anyway.
If you do think of a way to get the array value, please do share :-)

@ValentinH
Copy link
Member

Getting the array value is easy, just access it with the index. The problem is to bind it to a text input...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants