Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Slider.js - value always set to max on setRange #1192

Merged
merged 2 commits into from

3 participants

@drgould

When changing the range of a slider it would always change the value of the slider to the max of the range.

@drgould drgould Slider - fixed value always max on setRange
When changing the range of a slider it would always change the value of the slider to the max of the range.
5e18430
Source/Drag/Slider.js
@@ -160,7 +160,7 @@ var Slider = new Class({
this.steps = this.options.steps || this.full;
this.stepSize = Math.abs(this.range) / this.steps;
this.stepWidth = this.stepSize * this.full / Math.abs(this.range);
- if (range) this.set(Array.pick([pos, this.step]).floor(this.min).max(this.max));
+ if (range) this.set(Array.pick([pos, this.step]).floor(this.max).max(this.min));
@arian Owner
arian added a note

huh, does Number:floor have arguments, iirc it's just Math.floor, but on the Number prototype, or am I missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@arian
Owner

Also i'd be really nice if you have a quick jsfiddle so we can verify the bug and fix.

@drgould

Here's the test: http://jsfiddle.net/LBM6T/

Not sure about Number.floor. Seems like it behaves like Number.min in this case.

@arian
Owner

I don't really see what's wrong with the current behavior.

I think the .floor(this.max).max(this.min) should be changed in .limit(this.min, this.max).

@drgould

Here is it without the fix: http://jsfiddle.net/vYSeA/

@arian
Owner

Ah, didn't see that your first jsfiddle actually contained the fix, that is indeed the correct behavior.
Could you try if .limit(this.min, this.max) works as well?

@drgould

Seems to be working correctly with .limit(this.min,this.max).

@arian arian merged commit 8d64841 into mootools:master
@arian
Owner

thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 4, 2013
  1. @drgould

    Slider - fixed value always max on setRange

    drgould authored
    When changing the range of a slider it would always change the value of the slider to the max of the range.
  2. @drgould
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  Source/Drag/Slider.js
View
2  Source/Drag/Slider.js
@@ -160,7 +160,7 @@ var Slider = new Class({
this.steps = this.options.steps || this.full;
this.stepSize = Math.abs(this.range) / this.steps;
this.stepWidth = this.stepSize * this.full / Math.abs(this.range);
- if (range) this.set(Array.pick([pos, this.step]).floor(this.min).max(this.max));
+ if (range) this.set(Array.pick([pos, this.step]).limit(this.min,this.max));
return this;
},
Something went wrong with that request. Please try again.