Skip to content

Instantly share code, notes, and snippets.

@markng
Created November 25, 2009 22:27
Show Gist options
  • Save markng/243071 to your computer and use it in GitHub Desktop.
Save markng/243071 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
var slider = null;
var sliderUl = null;
$('div.sliding').each(function() {
sliderUl = $('ul', this);
var productWidth = sliderUl.innerWidth() - $(this).outerWidth();
slider = $('#slider').slider({
animate: false,
min: 0,
max: productWidth,
slide: function (ev, ui) {
sliderUl.css('left', '-' + ui.value + 'px');
},
change: function (ev, ui) {
//sliderUl.animate({ 'left' : '-' + ui.value + 'px' }, 1500, 'linear');
}
});
});
var offset = $('div.sliding').position().left;
$('ul.cat-ul li a').each(function(index) {
$(this).bind('click', function(event) {
event.preventDefault();
var leftpos = $('div.sliding ul li.'+$(this).attr('class')+':first').position().left;
sliderUl.css('left', '-' + leftpos + 'px');
slider.slider('value', leftpos);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment