seiyria / bootstrap-slider

A slider control for Bootstrap 3 & 4.
http://seiyria.github.io/bootstrap-slider/
Other
3k stars 1.14k forks source link

Enhancement to the formatter option #927

Closed xavier-90 closed 4 years ago

xavier-90 commented 4 years ago

Hi,

When using the formatter there is no way of knowing if the formatter is being called for the lower value or upper value, useful information if you wish to display different information in the formatted value.

One option would be to call the formatter with a second argument, e.g.:

Line 1202 var formattedTooltipVal = this.options.formatter(!tempState ? this._state.value[0] : tempState.value[0], 'min'); Line 1274 formattedValue = this.options.formatter(this._state.value[0], 'min'); Line 1283 formattedValue = this.options.formatter(this._state.value[1], 'max'); Line 1424 var innerTooltipMinText = this.options.formatter(this._state.value[0], 'min'); Line 1427 var innerTooltipMaxText = this.options.formatter(this._state.value[1], 'max'); Line 1434 formattedTooltipVal = this.options.formatter(this._state.value[0], 'min');

Thanks, Xav

seiyria commented 4 years ago

If you have the value, you can check against the slider bounds by getting the slider current value, and seeing if you have the min or max. I'm not sure how well this solution works for non-range sliders, also.

xavier-90 commented 4 years ago

I think you have misunderstood my request: I have implemented a split range slider. Out of the 2 values a user can change I need to know which one is being changed. The lower value or the upper value. I do not think there is any way of determining this within the formatter. Comparing against current set values is not an option as both values could change in one action. e.g. dragging the lower value beyond the upper value result in both values being updated.