Slider: Improve behaviour on overlapping ranges

Improve the handle detection when they overlap in slider ranges.
This commit is contained in:
Gon GArce 2023-07-29 02:31:49 +02:00
parent 1be4538817
commit a50e2af383

View File

@ -198,6 +198,19 @@ return $.widget( "ui.slider", $.ui.mouse, {
position = { x: event.pageX, y: event.pageY };
normValue = this._normValueFromMouse( position );
if ( this.options.range === true && this.values( 0 ) === this.values( 1 ) ) {
if ( this.values( 0 ) === this._valueMin() ) {
index = 1;
} else if ( this.values( 0 ) === this._valueMax() ) {
index = 0;
} else {
index = normValue === this.values( 0 ) ?
this._lastChangedValue :
Number( normValue > this.values( 0 ) );
}
closestHandle = $( this.handles[ index ] );
} else {
distance = this._valueMax() - this._valueMin() + 1;
this.handles.each( function( i ) {
var thisDistance = Math.abs( normValue - that.values( i ) );
@ -209,6 +222,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
index = i;
}
} );
}
allowed = this._start( event, index );
if ( allowed === false ) {