egorkhmelev / jslider

jQuery Slider plugin (THIS PROJECT IS NOT MAINTAINED ANYMORE, READ BELOW FOR MORE INFO)
http://egorkhmelev.github.com/jslider
MIT License
507 stars 203 forks source link

how to make slider snap to increments? #15

Open hau opened 12 years ago

hau commented 12 years ago

This is a great plugin.

I was wondering though, how do you make jquery.slider snap to increments? For example, I want to make a slider with values 1-10. I only want the slider to be placed on the integer values within the range. I don't want the slider handle to settle at a position between integer values. I didn't see such behaviour in the demos. Can it be done?

ghepting commented 12 years ago

I second this feature request. Looking into adding this feature to the plugin.

azizmb commented 12 years ago

+1

letronje commented 12 years ago

+1

avesel commented 12 years ago

Hi!

The way I solved this is by adding the callback function and setting the value to itself.

Alex

jQuery(document).ready(function(){

jQuery("#Slider1").slider({
    from: 0, 
    to: 100, 
    step: 10, 
    dimension: '%',
    limits: false,
    scale: ['0', '|', '20', '|', '40', '|', '60', '|', '80', '|', '100'],
    onstatechange: function( value ){
        textEditBoxTest.value = value;
    },
    callback: function( value ){
         jQuery("#Slider1").slider("value", value);   
    }
});

});

norquest commented 12 years ago

Hi, if you look at the code there is a setting for 'smooth:true' Set it to false and it will snap to each point.

Corey