aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorPaul Bakaus <paul.bakaus@googlemail.com>2009-01-28 19:10:37 +0000
committerPaul Bakaus <paul.bakaus@googlemail.com>2009-01-28 19:10:37 +0000
commitbf6b493c901d3728cae05811c21b659ff2e13c2d (patch)
tree2a3d52e0e2eb5f983d7c98e144eecf8c75289547 /ui
parentbdf7d24caeb2d851878a3fa2591911c934d29d34 (diff)
downloadjquery-ui-bf6b493c901d3728cae05811c21b659ff2e13c2d.tar.gz
jquery-ui-bf6b493c901d3728cae05811c21b659ff2e13c2d.zip
slider:
- when dragging a handle, the position of the relative click is respected (fixes #3972) - when dragging two range handles to 0, the slider was broken because the nearest handle would always be the first. Implemented a workaround. (fixes #3736)
Diffstat (limited to 'ui')
-rw-r--r--ui/ui.slider.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/ui/ui.slider.js b/ui/ui.slider.js
index 199932a29..20a72c89c 100644
--- a/ui/ui.slider.js
+++ b/ui/ui.slider.js
@@ -195,13 +195,26 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
index = i;
}
});
+
+ //workaround for bug #3736
+ if(o.range && (this.values(0) + this.values(1)) == 0) {
+ closestHandle = $(this.handles[++index]);
+ }
self._handleIndex = index;
closestHandle
.addClass("ui-state-active")
.focus();
+
+ var offset = closestHandle.offset();
+ var mouseOverHandle = !$(event.target).parents().andSelf().is('.ui-slider-handle');
+ this.clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
+ left: event.pageX - offset.left + (parseInt(closestHandle.css('marginLeft')) || 0),
+ top: event.pageY - offset.top + (parseInt(closestHandle.css('marginTop')) || 0)
+ }
+ normValue = this._normValueFromMouse(position);
this._slide(event, index, normValue);
return true;
@@ -229,6 +242,7 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
this._stop(event);
this._change(event);
this._handleIndex = null;
+ this.clickOffset = null;
return false;
@@ -239,10 +253,10 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
var pixelTotal, pixelMouse;
if ('horizontal' == this.orientation) {
pixelTotal = this.elementSize.width;
- pixelMouse = position.x - this.elementOffset.left;
+ pixelMouse = position.x - this.elementOffset.left - (this.clickOffset ? this.clickOffset.left : 0);
} else {
pixelTotal = this.elementSize.height;
- pixelMouse = position.y - this.elementOffset.top;
+ pixelMouse = position.y - this.elementOffset.top - (this.clickOffset ? this.clickOffset.top : 0);
}
var percentMouse = (pixelMouse / pixelTotal);
@@ -303,8 +317,10 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
handle: handle,
value: newVal
});
- if (allowed !== false)
+ if (allowed !== false) {
this._setData('value', newVal);
+ }
+
}
}