jQuery slider “slide” event: How do I determine the user's slide direction?

前端 未结 3 1581
情深已故
情深已故 2021-01-21 17:49

I have been dissecting the event and ui objects in firebug but it doesn\'t seem to have anything I can use. Am I missing something? I suppose I can keep track of the value chang

3条回答
  •  长发绾君心
    2021-01-21 17:58

    Easy solution is simply to use negative range (instead of [1 - 10] use [-10 , -1]:

            $("#slider-roomsrange").slider({
            range: true,
            min: -10,
            max: -1,
            step: -.5,
            values: [-3, -1],
            slide: function (event, ui) {
                $("#roomsfrom").val((ui.values[0]*-1));
                $("#roomsto").val((ui.values[1]*-1));
               // $("#rooms").val(ui.values[1] + " - " + ui.values[0]);
            }
        });
    

    I'm reversing the value to be positive by using *-1 and works gret.

    *Only problem I have at the moment is that the step is 1 and not .5 as I expected.

提交回复
热议问题