Skip to content

Commit

Permalink
Slider: Reset positioning when orientation changes
Browse files Browse the repository at this point in the history
Fixes #10105
Closes gh-1268
  • Loading branch information
scottgonzalez committed Jul 2, 2014
1 parent 7c4c86a commit 15baf02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/unit/slider/slider_options.js
Expand Up @@ -78,7 +78,7 @@ test( "min", function() {
});

test( "orientation", function() {
expect( 6 );
expect( 8 );
element = $( "#slider1" );

options = {
Expand All @@ -93,6 +93,7 @@ test( "orientation", function() {
element.slider( options ).slider( "option", "orientation", "horizontal" );
ok( element.is( ".ui-slider-horizontal" ), "horizontal slider has class .ui-slider-horizontal" );
ok( !element.is( ".ui-slider-vertical" ), "horizontal slider does not have class .ui-slider-vertical" );
equal( element.find( ".ui-slider-handle" )[ 0 ].style.bottom, "", "CSS bottom reset" );
equal( handle()[0].style.left, percentVal + "%", "horizontal slider handle is positioned with left: %" );

element.slider( "destroy" ) ;
Expand All @@ -109,6 +110,7 @@ test( "orientation", function() {
element.slider( options ).slider( "option", "orientation", "vertical" );
ok( element.is( ".ui-slider-vertical" ), "vertical slider has class .ui-slider-vertical" );
ok( !element.is( ".ui-slider-horizontal" ), "vertical slider does not have class .ui-slider-horizontal" );
equal( element.find( ".ui-slider-handle" )[ 0 ].style.left, "", "CSS left reset" );
equal( handle()[0].style.bottom, percentVal + "%", "vertical slider handle is positioned with bottom: %" );

element.slider( "destroy" );
Expand Down
3 changes: 3 additions & 0 deletions ui/slider.js
Expand Up @@ -454,6 +454,9 @@ return $.widget( "ui.slider", $.ui.mouse, {
.removeClass( "ui-slider-horizontal ui-slider-vertical" )
.addClass( "ui-slider-" + this.orientation );
this._refreshValue();

// Reset positioning from previous orientation
this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
break;
case "value":
this._animateOff = true;
Expand Down

0 comments on commit 15baf02

Please sign in to comment.