jslider icon indicating copy to clipboard operation
jslider copied to clipboard

how to make slider snap to increments?

Open hau opened this issue 13 years ago • 5 comments
trafficstars

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?

hau avatar May 27 '12 02:05 hau

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

ghepting avatar Jun 07 '12 17:06 ghepting

+1

azizmb avatar Jun 20 '12 12:06 azizmb

+1

letronje avatar Jun 20 '12 12:06 letronje

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);   
    }
});

});

avesel avatar Jul 26 '12 04:07 avesel

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

norquest avatar Aug 15 '12 14:08 norquest