Skip to content

Commit

Permalink
Do not allow negative step values
Browse files Browse the repository at this point in the history
  • Loading branch information
abpetkov committed Apr 21, 2014
1 parent 7a890e8 commit 35e53d5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Powerange.prototype.setValue = function (offset, size) {

Powerange.prototype.step = function(sliderSize, handleSize) {
var dimension = sliderSize - handleSize
, part = percentage.from(this.options.step, this.options.max - this.options.min)
, part = percentage.from(this.checkStep(this.options.step), this.options.max - this.options.min)
, interval = percentage.of(part, dimension)
, steps = [];

Expand All @@ -219,6 +219,20 @@ Powerange.prototype.checkValues = function(start) {
if (this.options.min >= this.options.max) this.options.min = this.options.max;
};

/**
* Make sure `step` is positive.
*
* @param {Number} value
* @returns {Number} this.options.step
* @api private
*/

Powerange.prototype.checkStep = function(value) {
if (value < 0) value = Math.abs(value);
this.options.step = value;
return this.options.step;
};

/**
* Disable range slider.
*
Expand Down

0 comments on commit 35e53d5

Please sign in to comment.