Skip to content

Commit 3aa77c5

Browse files
author
Valentin Hervieu
committed
Fix ticks values when step is a float.
1 parent fef8c8b commit 3aa77c5

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

demo/index.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,17 @@ <h2>Slider with ticks value example</h2>
107107
<h2>Slider with ticks value and visible bar example</h2>
108108
Value: {{ priceSlider6 | json }}
109109
<rzslider rz-slider-model="priceSlider6"
110-
rz-slider-floor="0"
111-
rz-slider-ceil="10"
110+
rz-slider-floor="0.5"
111+
rz-slider-ceil="1.5"
112+
rz-slider-step="0.1"
113+
rz-slider-precision="1"
112114
rz-slider-always-show-bar="true"
113115
rz-slider-show-ticks-value="true"></rzslider>
114116
</article>
115117

116118
<article>
117119
<h2>Range Slider with ticks value example</h2>
118-
Value: {{ priceSlider6 | json }}
120+
Value: {{ priceSlider7 | json }}
119121
<rzslider rz-slider-model="priceSlider7.min"
120122
rz-slider-high="priceSlider7.max"
121123
rz-slider-floor="0"
@@ -180,7 +182,7 @@ <h2>Disabled slider example</h2>
180182
$scope.priceSlider3 = 250;
181183
$scope.priceSlider4 = 5;
182184
$scope.priceSlider5 = 5;
183-
$scope.priceSlider6 = 5;
185+
$scope.priceSlider6 = 1;
184186
$scope.priceSlider7 = {
185187
min: 2,
186188
max: 8

dist/rzslider.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,11 @@ function throttle(func, wait, options) {
680680
var positions = '',
681681
ticksCount = Math.round((this.maxValue - this.minValue) / this.step) + 1;
682682
for (var i = 0; i < ticksCount; i++) {
683-
var selectedClass = this.isTickSelected(i) ? 'selected': '';
683+
var value = this.roundStep(this.minValue + i * this.step);
684+
var selectedClass = this.isTickSelected(value) ? 'selected': '';
684685
positions += '<li class="tick '+ selectedClass +'">';
685686
if(this.showTicksValue)
686-
positions += '<span class="tick-value">'+ this.getDisplayValue(i) +'</span>';
687+
positions += '<span class="tick-value">'+ this.getDisplayValue(value) +'</span>';
687688
positions += '</li>';
688689
}
689690
this.ticks.html(positions);

dist/rzslider.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)