Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 39 additions & 6 deletions js/ion.rangeSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
this.is_active = false;
this.is_resize = false;
this.is_click = false;
this.is_change = false;

options = options || {};

Expand Down Expand Up @@ -1378,11 +1379,11 @@
return;
}

if (!this.dragging && !this.force_redraw && !this.is_key) {
if (!this.dragging && !this.force_redraw && !this.is_key && !this.is_change) {
return;
}

if (this.old_from !== this.result.from || this.old_to !== this.result.to || this.force_redraw || this.is_key) {
if (this.old_from !== this.result.from || this.old_to !== this.result.to || this.force_redraw || this.is_key || this.is_change) {

this.drawLabels();

Expand Down Expand Up @@ -1435,6 +1436,7 @@
this.is_start = false;
this.is_key = false;
this.is_click = false;
this.is_change = false;
this.force_redraw = false;
},

Expand Down Expand Up @@ -2134,17 +2136,25 @@
return decorated;
},

updateFrom: function () {
this.result.from = this.options.from;
updateFrom: function (from) {
if(from === undefined || from === null) {
from = this.options.from
}

this.result.from = from;
this.result.from_percent = this.convertToPercent(this.result.from);
this.result.from_pretty = this._prettify(this.result.from);
if (this.options.values) {
this.result.from_value = this.options.values[this.result.from];
}
},

updateTo: function () {
this.result.to = this.options.to;
updateTo: function (to) {
if(to === undefined || to === null) {
to = this.options.to
}

this.result.to = to;
this.result.to_percent = this.convertToPercent(this.result.to);
this.result.to_pretty = this._prettify(this.result.to);
if (this.options.values) {
Expand Down Expand Up @@ -2380,6 +2390,29 @@
this.init(true);
},

/**
* Changes 'from' and 'to' plugin values, specified in options object.
*
* @param options {Object} - New values fo from and to: {from: value, to: value}.
*/
change: function(options) {
if (!this.input) {
return;
}

if(typeof options !== 'object'){
return;
}

if(options.from !== undefined) this.updateFrom(options.from);
if(options.to !== undefined) this.updateTo(options.to);
this.is_change = true;
this.target = "base";
this.calc(true);

this.drawHandles();
},

reset: function () {
if (!this.input) {
return;
Expand Down
8 changes: 7 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,20 @@ var slider = $("#range").data("ionRangeSlider");
slider.reset();
```

There are 3 public methods:
There are 4 public methods:
```javascript
// UPDATE - updates slider to any new values
slider.update({
from: 300,
to: 400
});

// CHANGE - changes slider current from and/or to values, without recreating slider instance unlike the update method.
slider.change({
from: 300,
to: 400
});

// RESET - reset slider to it's first values
slider.reset();

Expand Down