Jump to content
  • Advertisement
Sign in to follow this  
jbosch

doing the math to move a scroll bar

This topic is 2429 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I have some elements that are scrolled on the screen using a touch input. That works perfectly. Now I want to draw a scrollbar, with a proportional width, and move it among the "scroll visible area" proportionally to the user drag. Do you have any idea how could I make that?

scroll.jpg

thanks!

Share this post


Link to post
Share on other sites
Advertisement
Hi. You need to know current normalazed (i.e. from 0 to 1) offset of elments. According to tour picture, you can take current x of elements and divide it by total width of elements. So you'll get value from 0 to 1 (you may need to play with sign +/- to get absolute value). Now when you know ratio, you can easily set x position of scrollbar. This is simplest algorithm, but you can improve it taking into account width of visible area and width of scrollbar.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!