User:Mfaizsyahmi/scrollgallery.js

/* TURNS THE SCROLL GALLERY INTO A SLIDING GALLERY * by mfaizsyahmi, 2015 * NOTE: animation is painfully slow on my end, * even though it's correctly specified (400ms) * ALSO NOTE: Currently only works well for galleries that * doesn't exceed twice the container's width. The calculations for multi-page * galleries isn't hard to implement but isn't needed atm */

$('.scrollgallery-outer').each( function {	var g = $('.scrollgallery-inner',this);//,		w1 = $(this).width,		w2 = g.width;		//x = g.css('left'); // would be 0 initially;	var prev = $(' ').addClass('scrollgallery-prev').html(' '),		next = $(' ').addClass('scrollgallery-next').html(' ');	prev.on('click', function(e) { g.animate({left:0},400); prev.hide; next.show; });	next.on('click', function(e) { var dx = w1 - w2; g.animate({left:dx},400); next.hide; prev.show; });	prev.hide;// initial	$(this).prepend(prev).prepend(next); });