You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
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: