jQuery UI Sliders - Select overlapping sliders based on dragging direction

前端 未结 7 1597
猫巷女王i
猫巷女王i 2021-01-02 11:27

I have this simple jQuery UI Slider setup with a range and a two default values that overlap. The entire thing (with a few bells and whistles) can be found in this jsfiddle:

7条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-02 12:17

    Another solution: Test for both values and if they are the same, return to the last step.

     $("#slider").slider({ 
                range:true, 
                min:0, 
                max:250,
                step: 25,
                slide: function( event, ui ) {
                    if (ui.values[0] == ui.values[1]){
                        return false;
                    }else{
                        $( "#amount" ).html( "€" + ui.values[0] + " - €" + ui.values[1] );
                    }
                }
          });
    

提交回复
热议问题