Skip to content

Instantly share code, notes, and snippets.

@laurendavissmith
Created May 15, 2013 20:03
Show Gist options
  • Save laurendavissmith/5586919 to your computer and use it in GitHub Desktop.
Save laurendavissmith/5586919 to your computer and use it in GitHub Desktop.
allowing@koken Boulevard previous click to return to beginning of #album-intro
var scrollTo = function() {
if ( imgViewing >= totalImgs ) {
imgViewing = ( totalImgs - 1 );
} else if ( imgViewing < 0 ) {
imgViewing = 0;
}
var newLeftPos = $('#lane img:eq(' + imgViewing + ')').closest('.cell').offset().left;
if (imgViewing === 0 && $('#album-intro').length) {
newLeftPos = 0;
}
$('html,body').stop().animate({
scrollLeft: ( newLeftPos - 80 )
}, 400, function(x, t, b, c, d) {
var s=1.70158;var p=0;var a=c;
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
if (a < Math.abs(c)) { a=c; var s=p/4; }
else var s = p/(2*Math.PI) * Math.asin (c/a);
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment