Scroll if on the right side (jQuery)
i have create a gallery with jquery.
http://www.rialto-design.de/end开发者_Python百科kunden/galerie/galerie-armaturen/?album=3&gallery=2
so my question is, how can i make the thumbs scroll left or right. when the cursor is on the right or left side of the container.
Important is, the thubs are still clickable.
Thx
Try adding the code below, then removing the img_forward
and img_back
hover functions.
var overview = $('.ngg-galleryoverview'),
// vp = viewport width
vp = overview.width(),
// edgeMargin = margin to add on either side of the thumbs
edgeMargin = 20,
// maxw = width of all thumbs together side-by-side
maxw = $('.gallery_thumbs').css('padding','0 ' + edgeMargin + 'px').outerWidth();
overview.bind('mousemove', function(e){
overview.scrollLeft( (e.pageX - overview.offset().left) * (maxw - vp) / vp );
});
Update: Added comments to the code to prevent someone in the future from cursing my name trying to figure out what is going on.
精彩评论