cool js function I wrote to determine the left index of a photo carousel
function determine_left_index(len){
/*
If the number of locations doesn't divide equally
into three perform a function on that number that
will determine the index we should point to.
Example:
len = 20 // twenty photo objects
len % 3 == 0 // returns false, 20 does not divide equally into 3
len/3 // returns 6.666...
(len/3)|0 // returns 6 which says we have six screens of three photos
(((len/3)|0)*3) // returns 18 which says we should point our left index
// at 18 and the visited locations will display the photos
// at index 18 and 19.
*/
if (len % 3 === 0){
return photo_objects.length - 3;
} else {
return (((len/3)|0)*3);
}
}