info343/lectures/special-effects/files/gallery.js

// gallery.js
// JavaScript code for sliding image gallery example, Lecture 8: Special Effects
// INFO 343, Autumn 2012
// Morgan Doocy

// Attach a click handler to all links when the page is ready.
$(document).ready(function() {
   $('a').click(linkClick);
});

// Set the 'transform' property of the photo we want to display.
function linkClick() {
   // A little hackish, but this gets the number from the text inside the link.
   var num = $(this).text().split(/ /)[1];
   
   // Translate #slider by the correct number of pixels to show the image.
   $('#slider').css('transform', 'translate(' + (num-1) * -450 + 'px, 0)');
}