开发者

Weird jQuery UI Slider behavior using Page Up/Down

开发者 https://www.devze.com 2023-01-01 18:19 出处:网络
I\'m using jQuery UI\'s slider to update a div containing a number. Dragging or using the left/right keys should only allow the user to choose a number between 1 and 5 (this works as intended). Howeve

I'm using jQuery UI's slider to update a div containing a number. Dragging or using the left/right keys should only allow the user to choose a number between 1 and 5 (this works as intended). However, if the handle has focus and I use page up/down, I start to get rounded values that are well out of the range of 1-5. Anybody exp开发者_如何学Cerience the same? Thoughts?


Here is the code from the JQuery.UI reopsitory. It looks to me like it may be a bug. You might want to report this here (you'll probably need to register.) BTW the feature was added only seven months ago see here.

   switch ( event.keyCode ) {
        case $.ui.keyCode.HOME:
                newVal = self._valueMin();
                break;
        case $.ui.keyCode.END:
                newVal = self._valueMax();
                break;
        case $.ui.keyCode.PAGE_UP:
                newVal = curVal + ( (self._valueMax() - self._valueMin()) / numPages );
                break;
        case $.ui.keyCode.PAGE_DOWN:
                newVal = curVal - ( (self._valueMax() - self._valueMin()) / numPages );
                break;
        case $.ui.keyCode.UP:
        case $.ui.keyCode.RIGHT:
                if ( curVal === self._valueMax() ) {
                        return;
                }
                newVal = curVal + step;
                break;
        case $.ui.keyCode.DOWN:
        case $.ui.keyCode.LEFT:
                if ( curVal === self._valueMin() ) {
                        return;
                }
                newVal = curVal - step;
                break;
   }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号