0

在 1.9.2 中使用默认的 ui-slider 时,两个把手碰撞时会出现一个小问题,无法拖动右侧把手。

见这里:http: //jqueryui.com/slider/#range

将两个车把放在一起,然后尝试增加较高的值,不起作用。

然后我发现了这个帖子:

https://stackoverflow.com/a/4254932/1905754

这是一个解决方案,但它适用于 1.8.6,所以我在 1.9.2 中找不到要编辑的那些代码行。有人知道 1.9.2 是否有类似的解决方案?

谢谢。

抱歉英文不正确。

4

3 回答 3

0

尝试在 jquery.ui.js 中找到以下代码(函数 _mouseCapture,第 12313 行)

        // workaround for bug #3736 (if both handles of a range are at 0,
        // the first is always used as the one with least distance,
        // and moving it is obviously prevented by preventing negative ranges)
        if( o.range === true && this.values(1) === o.min ) {
            index += 1;
            closestHandle = $( this.handles[index] );
        }

        // my fix
        if( o.range === true && this.values(1) === this.values(0) ) {
            if(normValue <= this.values(0)){
                index = 0;
            }
            else {
                index = 1;
            }
            closestHandle = $( this.handles[index] );
        }
        // end of my fix
于 2012-12-30T15:28:12.010 回答
0

这不是永久修复,但有助于使滑块可拖动。

$('#slider-range').slider
  start: (event, ui) ->
    # Only when sliders are overriding
    if ui.values[0] == ui.values[1]
      set_min = ui.values[0] - 0.1
      set_max = ui.values[1]
      # Deducing value of left slider by 0.1(or you can give step value based on your condition)
      $('#slider-range').slider('values', [set_min,set_max])
      return false
   slide: (event, ui) ->
     # Some statements
   stop: (event, ui) ->
     # Some statements
于 2017-01-18T04:13:50.183 回答
0

我建议替换此代码 _mouseCapture

this.handles.each(function( i ) {
        var thisDistance = Math.abs( normValue - that.values(i) );
        if (( distance > thisDistance ) ||
            ( distance === thisDistance &&
                (i === that._lastChangedValue || that.values(i) === o.min ))) {
            distance = thisDistance;
            closestHandle = $( this );
            index = i;
        }
    });

this.handles.each(function( i ) {
        if (event.target == that.handles[i]) {
            index = i;
            closestHandle = $( this );
        }
    });
于 2016-08-03T12:40:55.293 回答