-
Notifications
You must be signed in to change notification settings - Fork 231
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
Thumb Incorrect positioning #302
Comments
Try with multiplying the ratio by the width of the bar and then subtract half the width of the thumb. This will correctly calculate the position of the thumb on the slider. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Hello! I noticed that the formula for calculating the position of the thumb in the calcOffset method is incorrect.
The width of the thumb is subtracted from the width of the bar before being multiplied by the ratio, when the correct calculation would be to first multiply the ratio by the width of the bar, and then subtract half the width of the thumb.
Eg:
Block width 400px, thumb width 16px, selection range 0-100.
If the thumb is at 40, then its position will be equal to
400 * ((40 - 0) / 100) - (16 / 2) = 400 * 0.4 - 8 = 160 - 8 = 152px;
According to the current formula:
(400 - 16) * ((40 - 0) / 100) = 384 * 0.4 = 153.6;
The values are very close and the error is difficult to see with the naked eye. The correct position is calculated only for the middle of the bar, before and after it will be a little more or a little less, respectively
The text was updated successfully, but these errors were encountered: