Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Progress bar continuing onto second screen after reaching 100%

ANSWERED

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.
steps1.jpgsteps2.jpg

 

Thank you in advance

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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);

View best answer in original post

Best Answer
0 Votes
2 REPLIES 2

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);
Best Answer
0 Votes

That's done the job @JonFitbit , thank you so much. Exactly what was needed.

 

Cheers very much

Mark.

Best Answer
0 Votes