brogan123
Newbie
Posts: 1
Registered: 7/2/2008
Location: sf, ca
Member Is Offline
|
| posted on 7/2/2008 at 09:32 PM |
|
|
slider header
Lets say I have a slider for 1-5 values. I want to have a header above the slider bar that says: 1 2 3 4 5 where each numeric label *exactly* matches
the position of the actual slider knob for that value.
Is there any way to know with some kind of formula or something exactly where the slider's knob will "tick" into place?
I have several sliders of different scales that I want to do this for so I'd love to have some kind of algorithm I could use to generate the header
but I can't figure out exactly what pixel position the slider knob is going to stop at for each value.
Also, would it be better to try and do this with an html table or just build a hardcoded image for the scale?
|
|
|
tigra
Administrator
Posts: 2043
Registered: 6/17/2002
Location: US, CO
Member Is Offline
|
| posted on 7/3/2008 at 08:06 PM |
|
|
1. create the graphics for the slider's body with the notches and their labels. notches must be equally spaced. set n_controlWidth and
n_controlHeight by the size of the image
2. set n_minValue, n_maxValue and n_step
(n_maxValue - n_minValue) must be multiple of n_step
Your graphics should have abs(n_maxValue - n_minValue) / n_step + 1 notches
3. set n_pathLeft and n_pathTop so the knob is right over the first notch when value is set to n_minValue (n_maxValue if b_reverse == true)
4. set n_pathLength so the knob is right over the last notch when value is set to n_maxValue (n_minValue if b_reverse == true)
the slider will make sure that it snaps the knob to the nearest notch in between.
If you need to generate different sliders dynamically you can generate the body of the control in HTML (with notches, labels etc), configure the
script accordingly and position it over that body.
|
|
|