Fixed values for a Titanium.UI.Slider object
I want my slider to have a value in a range between 0 and 100, but instead of allowing all numbers in the range I want to restrict the user to select certain values only, for example: 10, 15, 20, 25 and so on.
Any thoughts?
2 Answers
-
I think you will need to
preventDefault()
on the various touch events and write your own code in those events to track the user's finger on the slider, manually setting the slider to the nearest valid value as the finger moves along.It may be possible to avoid the tracking by just setting the slider to the nearest value directly on the touch events, but I suspect this might create some visual 'snap to value' anomalies - may or may not be what you're after. Worth trying though.
-
Thsi is what I've done with my slider which only shows the whole number.
// Create sliding event handler sliderAge.addEventListener('change', function(e){ var nAge = Math.round(e.value); sliderLabelAge.text = nAge; });