mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Fixed #4292 (Slider: ui.value incorrect in slide event if handle at value 0)
This commit is contained in:
parent
3943e3d97c
commit
439d93bf8b
@ -299,7 +299,11 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_start: function(event, index) {
|
_start: function(event, index) {
|
||||||
this._trigger("start", event, this._uiHash(index));
|
this._trigger("start", event, {
|
||||||
|
handle: this.handles[index],
|
||||||
|
value: this.value(),
|
||||||
|
values: this.values()
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_slide: function(event, index, newVal) {
|
_slide: function(event, index, newVal) {
|
||||||
@ -317,7 +321,11 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
|
|||||||
var newValues = this.values();
|
var newValues = this.values();
|
||||||
newValues[index] = newVal;
|
newValues[index] = newVal;
|
||||||
// A slide can be canceled by returning false from the slide callback
|
// A slide can be canceled by returning false from the slide callback
|
||||||
var allowed = this._trigger("slide", event, this._uiHash(index, newVal, newValues));
|
var allowed = this._trigger("slide", event, {
|
||||||
|
handle: this.handles[index],
|
||||||
|
value: newVal,
|
||||||
|
values: newValues
|
||||||
|
});
|
||||||
var otherVal = this.values(index ? 0 : 1);
|
var otherVal = this.values(index ? 0 : 1);
|
||||||
if (allowed !== false) {
|
if (allowed !== false) {
|
||||||
this.values(index, newVal, ( event.type == 'mousedown' && this.options.animate ), true);
|
this.values(index, newVal, ( event.type == 'mousedown' && this.options.animate ), true);
|
||||||
@ -328,7 +336,10 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
|
|||||||
|
|
||||||
if (newVal != this.value()) {
|
if (newVal != this.value()) {
|
||||||
// A slide can be canceled by returning false from the slide callback
|
// A slide can be canceled by returning false from the slide callback
|
||||||
var allowed = this._trigger("slide", event, this._uiHash(index, newVal));
|
var allowed = this._trigger("slide", event, {
|
||||||
|
handle: this.handles[index],
|
||||||
|
value: newVal
|
||||||
|
});
|
||||||
if (allowed !== false) {
|
if (allowed !== false) {
|
||||||
this._setData('value', newVal, ( event.type == 'mousedown' && this.options.animate ));
|
this._setData('value', newVal, ( event.type == 'mousedown' && this.options.animate ));
|
||||||
}
|
}
|
||||||
@ -340,11 +351,27 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_stop: function(event, index) {
|
_stop: function(event, index) {
|
||||||
this._trigger("stop", event, this._uiHash(index));
|
var uiHash = {
|
||||||
|
handle: this.handles[index],
|
||||||
|
value: this.value()
|
||||||
|
};
|
||||||
|
if (this.options.values && this.options.values.length) {
|
||||||
|
uiHash.value = this.values(index)
|
||||||
|
uiHash.values = this.values()
|
||||||
|
}
|
||||||
|
this._trigger("stop", event, uiHash);
|
||||||
},
|
},
|
||||||
|
|
||||||
_change: function(event, index) {
|
_change: function(event, index) {
|
||||||
this._trigger("change", event, this._uiHash(index));
|
var uiHash = {
|
||||||
|
handle: this.handles[index],
|
||||||
|
value: this.value()
|
||||||
|
};
|
||||||
|
if (this.options.values && this.options.values.length) {
|
||||||
|
uiHash.value = this.values(index)
|
||||||
|
uiHash.values = this.values()
|
||||||
|
}
|
||||||
|
this._trigger("change", event, uiHash);
|
||||||
},
|
},
|
||||||
|
|
||||||
value: function(newValue) {
|
value: function(newValue) {
|
||||||
@ -475,19 +502,8 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
|
|||||||
(oRange == "max") && (this.orientation == "vertical") && this.range[animate ? 'animate' : 'css']({ height: (100 - valPercent) + '%' }, { queue: false, duration: o.animate });
|
(oRange == "max") && (this.orientation == "vertical") && this.range[animate ? 'animate' : 'css']({ height: (100 - valPercent) + '%' }, { queue: false, duration: o.animate });
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
_uiHash: function(index, value, values) {
|
|
||||||
|
|
||||||
var multiple = this.options.values && this.options.values.length;
|
|
||||||
return {
|
|
||||||
handle: this.handles[index],
|
|
||||||
value: value || (multiple ? this.values(index) : this.value()),
|
|
||||||
values: values || (multiple && this.values())
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
$.extend($.ui.slider, {
|
$.extend($.ui.slider, {
|
||||||
|
Loading…
Reference in New Issue
Block a user