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

Max value calculation wrong due to cutoff when max value is not a multiple of step #759

Merged
merged 8 commits into from
Jul 6, 2017

Conversation

thaitzer
Copy link

@thaitzer thaitzer commented Jul 4, 2017

gracefully handle max value when a step size is defined and the max v…alue does not fit the step size

@seiyria
Copy link
Owner

seiyria commented Jul 4, 2017

please add a unit test so this particular behavior doesn't happen anymore!

@seiyria
Copy link
Owner

seiyria commented Jul 4, 2017

additionally, please make sure this passes our linter!

Copy link
Collaborator

@rovolution rovolution left a comment

Choose a reason for hiding this comment

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

@thaitzer thanks for the contribution!

As @seiyria indicated, could you add a unit test to ensure the error that was occurring is no longer occurring + fix the code to pass the lint check? Thanks!

@thaitzer
Copy link
Author

thaitzer commented Jul 6, 2017

I have added the test and checked the linter.

However I have a problem with my test code. I did not find a useful way to get the outer right position for the slider right - i had to add 10px manually to the mouse-click. I do not know why this is the case but I figure you guys probably have a pointer for me :-). Then I will gladly fix the test and get rid of the "+10".

For the mouse-clicking I copied the method from another test - this is where codeclimate complains now about code duplication. What is your suggested way of fixing this?

min: 39,
max: 1310,
step: 5,
scale:"logarithmic",
Copy link
Collaborator

Choose a reason for hiding this comment

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

test is solid! could you fix the spacing on this line?

it("Value should contain max value when slider is moved to outer right position", function() {

var sliderLeft = slider.sliderElem.offsetLeft;
var offsetY = slider.sliderElem.offsetTop;
Copy link
Collaborator

Choose a reason for hiding this comment

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

spacing

var offsetY = slider.sliderElem.offsetTop;
var offsetX = sliderLeft + slider.sliderElem.clientWidth+10;

var expectedValue = slider.options.max;
Copy link
Collaborator

Choose a reason for hiding this comment

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

spacing

@rovolution
Copy link
Collaborator

However I have a problem with my test code. I did not find a useful way to get the outer right position for the slider right - i had to add 10px manually to the mouse-click. I do not know why this is the case but I figure you guys probably have a pointer for me :-). Then I will gladly fix the test and get rid of the "+10".

as long as you feel the +10 value is roughly accurate, that is fine. maybe include a comment in the test about why you are using this value

For the mouse-clicking I copied the method from another test - this is where codeclimate complains now about code duplication. What is your suggested way of fixing this?

Don't worry about this. I have been pondering completely removing the codeclimate check or just limiting it to the source directory.

@thaitzer
Copy link
Author

thaitzer commented Jul 6, 2017

I cleaned up the test code, added the comment and fixed the intendation.

@rovolution
Copy link
Collaborator

@thaitzer just pulled down your branch to run the examples page and it works great!

Thanks again for your contribution!

@rovolution rovolution merged commit f7219c3 into seiyria:master Jul 6, 2017
@rovolution
Copy link
Collaborator

@thaitzer btw, are there any existing issues from our issues list that this fix addresses?

I just want to ensure those get listed in our changelog.

https://github.com/seiyria/bootstrap-slider/issues

@rovolution
Copy link
Collaborator

@thaitzer
Copy link
Author

thaitzer commented Jul 7, 2017

@rovolution I did not check the issues before writing this mini-patch. So the answer is: not that I know of.

While I am writing this: I never bothered to check if the same thing happens on the linear scale - I might be a good idea to do that.

And: thank you guys, for creating and maintaining this cool project!

@rovolution
Copy link
Collaborator

While I am writing this: I never bothered to check if the same thing happens on the linear scale - I might be a good idea to do that.

if you find that this is also an issue, we would definitely appreciate another PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants