Hi peeps,
One for the math code heads.
I have a scroll bar that is scolling a project list (each project being dynamically loaded). Currently the buttons at either end of the scroll bar shift the list by x amount (being the height of a project window) so that the projects are lined up neatly in the view. You can see what I mean on the site (navigate to recent work and scroll the projets with the buttons)
http://www.mainframe.co.uk .
I am now adding drag function to the slider. This means the list moves freely in relation the slider being dragged. However, when the slider is released the project list won't be lined up correctly as it is dependant on the users final drag position.
So here is what I want to acheive. Say the list should move by 150 pixels each time so the projects stay lined up correctly. How do I find the nearest multiple of 150 to the new list position? Example, the user drags the slider and the list moves by 340 pixels. The list would need to move back to 300 and not forward to 450. Can I specify a multiple of 150 in the math.round script? Is this even possible?
Hope I've made my question clear enough.
Thanks for any input.
Regards, Carl