我如何制作一个带有两个句柄的jquery ui滑块;“推”;彼此
How can I make a jquery ui slider with two handles that "push" eachother?
我想使用jquery ui制作一个带有两个句柄的滑块,以便在它们之间保持最小的空间。如果左手柄试图越过右手柄,则应推动右手柄。反之亦然。这里有一个例子(不要介意重叠,这并不重要):
http://jsfiddle.net/SP5VQ/
只要移动缓慢,它就会工作,但如果鼠标移动过快,在"推"的情况下就会失败。我认为在"滑块"事件中设置滑块值可能有错误。
这很有效。我从$.ui.slider.prototype._slide
中复制了代码,并删除了检查左手柄是否大于右手柄的部分。现在运行良好。
http://jsfiddle.net/Nk8ap/
$.ui.slider.prototype._slide = function ( event, index, newVal ) {
var otherVal,
newValues,
allowed;
if ( this.options.values && this.options.values.length ) {
otherVal = this.values( index ? 0 : 1 );
if ( newVal !== this.values( index ) ) {
newValues = this.values();
newValues[ index ] = newVal;
// A slide can be canceled by returning false from the slide callback
allowed = this._trigger( "slide", event, {
handle: this.handles[ index ],
value: newVal,
values: newValues
} );
otherVal = this.values( index ? 0 : 1 );
if ( allowed !== false ) {
this.values( index, newVal, true );
}
}
} else {
if ( newVal !== this.value() ) {
// A slide can be canceled by returning false from the slide callback
allowed = this._trigger( "slide", event, {
handle: this.handles[ index ],
value: newVal
} );
if ( allowed !== false ) {
this.value( newVal );
}
}
}
}
相关文章:
- 停止jQuery UI滑块移动超过给定值
- jquery ui滑块上的滑块值
- 使用Jquery ui时滑块无法工作
- 当页面居中时,带有inputfield的jQuery ui滑块句柄不起作用
- jQuery UI滑块-防止多个句柄重叠
- 使用多个数据点的 Highcharts 中的 JQuery UI 滑块
- jQuery UI 滑块自定义步骤增量和加载时的逗号
- jQuery UI 滑块动画未更新 UI vValue
- 激发滑块's幻灯片事件jquery ui
- 从jQuery UI滑块更改为'noUiSlider'-用于更新动画进度滑块的函数
- 使用ajax和jquery ui滑块实现一个下拉框
- jQuery UI滑块干扰光滑的旋转木马
- 带有两个句柄的 jQuery UI 滑块 - 获取初始数据
- 我如何制作一个带有两个句柄的jquery ui滑块;“推”;彼此
- HTML5范围滑块值在使用jQuery(而不是UI)的过程中
- jQuery 滑块 UI 值与用于乘法计算的输入混合
- 使用按钮更新滑块 UI 值
- 在jquery滑块ui中为第二个句柄设置一个值
- 绑定类方法作为回调到jquery滑块UI组件
- Jquery滑块UI动态步长