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

前端 未结 3 1589
情深已故
情深已故 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:52

    If you want to get the direction (value decreases or increases) just use the start and slide event. Store the inital value in a variable when the start event is fired. After that just compare this stored value against the value the sliding event creates.

    Just combine different events.

    Before edit:

    Use the documented getter

    var orientation = $( ".selector" ).slider( "option", "orientation" );
    

    This option determines whether the slider has the min at the left, the max at the right or the min at the bottom, the max at the top. Possible values: 'horizontal', 'vertical'.

提交回复
热议问题