Alexander_F
Alexander_F

Reputation: 2877

Scroll if on the right side (jQuery)

i have create a gallery with jquery.

http://www.rialto-design.de/endkunden/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.

alt text

Important is, the thubs are still clickable.

Thx

Upvotes: 1

Views: 323

Answers (1)

Mottie
Mottie

Reputation: 86433

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.

Upvotes: 1

Related Questions