01-10-2021 05:49
01-10-2021 05:49
Hi all,
After managing to get the progress bar to display current steps vs goal (goal in this case is 10,000 steps), i'd noticed that when it passes the goal (IE 100% of steps total) the progress bar continues to draw onto the next screen in the simulator? I thought I saw someone post that this was an issue but for the life of me I can't find the post.
Basically, my question is, how do I stop drawing the progress bar when it hits 100% so it doesn't exceed the device width. I'd prefer to stop drawing rather than stop making the calculations.
Thank you in advance
Answered! Go to the Best Answer.
01-11-2021 02:14
01-11-2021 02:14
I guess it depends how you're calculating the width, but you want to make sure you don't set the width greater than the screen width.
function clamp(val, min, max) {
return val > max ? max : val < min ? min : val;
}
yourWidth = clamp(yourWidth, 0, 300);
01-11-2021 02:14
01-11-2021 02:14
I guess it depends how you're calculating the width, but you want to make sure you don't set the width greater than the screen width.
function clamp(val, min, max) {
return val > max ? max : val < min ? min : val;
}
yourWidth = clamp(yourWidth, 0, 300);
01-11-2021 02:25