Skip to content

Commit

Permalink
fix(slider): preventCrossover should only affect range sliders
Browse files Browse the repository at this point in the history
Fixes a regression introduces in 4b1d548
The preventCrossover setting affected single sliders as well, which prevented them to slider correctly.

Closes #1231
  • Loading branch information
ColinFrick authored and Sean committed Dec 22, 2019
1 parent 8b5625a commit 0224c87
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/definitions/modules/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ $.fn.slider = function(parameters) {
newPos = module.determine.pos(eventPos)
;
// Special handling if range mode and both thumbs have the same value
if(module.is.range() && settings.preventCrossover && module.thumbVal === module.secondThumbVal) {
if(settings.preventCrossover && module.is.range() && module.thumbVal === module.secondThumbVal) {
initialPosition = newPos;
$currThumb = undefined;
} else {
Expand Down Expand Up @@ -353,13 +353,13 @@ $.fn.slider = function(parameters) {
thumbSmoothVal = module.determine.smoothValueFromEvent(event)
;
if(!$currThumb.hasClass('second')) {
if(settings.preventCrossover) {
if(settings.preventCrossover && module.is.range()) {
value = Math.min(secondThumbVal, value);
thumbSmoothVal = Math.min(secondThumbVal, thumbSmoothVal);
}
thumbVal = value;
} else {
if(settings.preventCrossover) {
if(settings.preventCrossover && module.is.range()) {
value = Math.max(thumbVal, value);
thumbSmoothVal = Math.max(thumbVal, thumbSmoothVal);
}
Expand All @@ -381,7 +381,7 @@ $.fn.slider = function(parameters) {
module.unbind.slidingEvents();
},
keydown: function(event, first) {
if(module.is.range() && settings.preventCrossover && module.thumbVal === module.secondThumbVal) {
if(settings.preventCrossover && module.is.range() && module.thumbVal === module.secondThumbVal) {
$currThumb = undefined;
}
if(module.is.focused()) {
Expand Down Expand Up @@ -926,12 +926,12 @@ $.fn.slider = function(parameters) {
$currThumb = newValue <= module.get.currentThumbValue() ? $thumb : $secondThumb;
}
if(!$currThumb.hasClass('second')) {
if(settings.preventCrossover) {
if(settings.preventCrossover && module.is.range()) {
newValue = Math.min(module.secondThumbVal, newValue);
}
module.thumbVal = newValue;
} else {
if(settings.preventCrossover) {
if(settings.preventCrossover && module.is.range()) {
newValue = Math.max(module.thumbVal, newValue);
}
module.secondThumbVal = newValue;
Expand Down

0 comments on commit 0224c87

Please sign in to comment.