Skip to content

Precision for output and integral tooltips for display #17

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

mkoistinen
Copy link

Firstly, I'm surprised this slider isn't more popular. I needed a cross-platform-capable slider for my project and looked all over. It seems my choices were: JQuery-UI (which I think is a bit heavy for a simple slider), an HTML polyfill (there are ZERO that actually work across all platforms that I could find, besides, not all projects use HTML5) or roll my own. This project is simple enough that it provided 90% of what I needed, thank you!

I see there are some pending touch-support commits, I would love to see these merged soon.

Anyway, these commits work together. First is just a removal of trailing whitespace (a pet-peeve of mine). Second is the addition of precision control for output values IF a step is defined. So, if your step is 0.01, the output will be fixed to 2 decimal places. It seems silly that this would be required, but thanks to the fuzziness of floating point numbers, it is. If no step is defined, the output is as it was: not fixed.

Finally, I've added support for an integral tooltip-style display of the output (which is one reason why the output precision was required).

If step is not defined, there is no effect. Otherwise, the step defines
the resulting precision of the output values.  For example, if step is
0.1, then the precision is to the tenths of a unit.  If step is 0.01,
then the precision is to the 1/100 of a unit.  If step > 0, precision
is set to a full unit.
@mkoistinen
Copy link
Author

Oh, just to mention, to add the tooltip, just add tooltip: true to the settings object, or, use the attribute 'data-slider-tooltip=true' in the initial input as per the other options.

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.

2 participants