Skip to content

Commit 15baf02

Browse files
committed
Slider: Reset positioning when orientation changes
Fixes #10105 Closes jquerygh-1268
1 parent 7c4c86a commit 15baf02

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

tests/unit/slider/slider_options.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ test( "min", function() {
7878
});
7979

8080
test( "orientation", function() {
81-
expect( 6 );
81+
expect( 8 );
8282
element = $( "#slider1" );
8383

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

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

114116
element.slider( "destroy" );

ui/slider.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,9 @@ return $.widget( "ui.slider", $.ui.mouse, {
454454
.removeClass( "ui-slider-horizontal ui-slider-vertical" )
455455
.addClass( "ui-slider-" + this.orientation );
456456
this._refreshValue();
457+
458+
// Reset positioning from previous orientation
459+
this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
457460
break;
458461
case "value":
459462
this._animateOff = true;

0 commit comments

Comments
 (0)