ui-slider重叠滑块无法拖动
当使用1.9.2中的默认ui滑块时,当两个把手发生碰撞时会出现小问题,无法拖动右侧车把。
见这里: http : //jqueryui.com/slider/#range
将两个车把放在一起,然后尝试增加更高的值,而不是工作。
然后我发现这篇文章:
https://stackoverflow.com/a/4254932/1905754
这是一个解决方案,但它是1.8.6所以我没有找到要在1.9.2中编辑的代码行。 有没有人知道1.9.2是否有类似的解决方案?
谢谢。
抱歉英文不正确。
尝试在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
我建议替换此代码_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 ); } });
这不是永久修复,但有助于使滑块可拖动agian。
$('#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