Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Created September 5, 2011 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterdavis/1195895 to your computer and use it in GitHub Desktop.
Save walterdavis/1195895 to your computer and use it in GitHub Desktop.
var move = function(value, inner){
var h = (inner.getHeight() - inner.up('div').getHeight());
inner.style.top = (Math.round(value * h) * -1) + 'px';
}
var setup = function(thumb, track, inner, plus = null, minus = null){
var s = new Control.Slider(thumb,track, {
axis:'vertical',
onChange: function(value){
move(value, inner);
},
onSlide: function(value){
move(value, inner)
}
});
if(!!plus){
$(plus).observe(
'click',
function(evt){
s.setValue(s.value < 1 ? s.value + 0.1 : 1);
}
};
)
if(!!minus){
$(minus).observe(
'click',
function(evt){
s.setValue(s.value > 0 ? s.value - 0.1 : 0);
}
);
}
}
setup('slide1thumb', 'slide1track', 'slide1inner', 'plus1', 'minus1');
setup('slide2thumb', 'slide2track', 'slide2inner', 'plus2', 'minus2');
setup('slide3thumb', 'slide3track', 'slide3inner', 'plus3', 'minus3');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment