slider: fixed orientation detection

This commit is contained in:
Paul Bakaus 2009-01-29 15:13:47 +00:00
parent 8218b06307
commit bcee037715

View File

@ -20,8 +20,7 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
var self = this, o = this.options; var self = this, o = this.options;
this._keySliding = false; this._keySliding = false;
this._handleIndex = null; this._handleIndex = null;
this.orientation = o.orientation == 'auto' ? (this.element[0].offsetWidth/this.element[0].offsetHeight > 1 ? 'horizontal' : 'vertical') : o.orientation; this._detectOrientation();
this._mouseInit(); this._mouseInit();
this.element this.element
@ -249,6 +248,10 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
return false; return false;
}, },
_detectOrientation: function() {
this.orientation = this.options.orientation == 'auto' ? (this.element[0].offsetWidth/this.element[0].offsetHeight > 1 ? 'horizontal' : 'vertical') : this.options.orientation;
},
_normValueFromMouse: function(position) { _normValueFromMouse: function(position) {
@ -381,11 +384,11 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
switch (key) { switch (key) {
case 'orientation': case 'orientation':
this.orientation = this.options.orientation == 'auto' ? (this.element[0].offsetWidth/this.element[0].offsetHeight > 1 ? 'horizontal' : 'vertical') : this.options.orientation; this._detectOrientation();
this.element this.element
.removeClass("ui-slider-horizontal ui-slider-vertical") .removeClass("ui-slider-horizontal ui-slider-vertical")
.addClass("ui-slider-" + this._orientation()); .addClass("ui-slider-" + this.orientation);
this._refreshValue(); this._refreshValue();
break; break;
case 'value': case 'value':