Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix slider jumps to first value if value is not in stepsArray #626

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion src/rzslider.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,9 @@
var index = 0
for (var i = 0; i < this.options.stepsArray.length; i++) {
var step = this.options.stepsArray[i]
if (step === modelValue) {
var lastStep = i > 0 ? this.options.stepsArray[i - 1] : 0;

if (step === modelValue || (modelValue > lastStep && modelValue < step)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some context require here, will you add comments here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a stepsArray is given in the options and the value is set from the outside to a value that is not part of the stepsArray, currently the slider will jump to the first element in the stepsArray. I changed it so that if the value is between two values the slider jumps to the higher value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this feature. However, could you add a test case for it?

index = i
break
} else if (angular.isDate(step)) {
Expand Down