Skip to content

Instantly share code, notes, and snippets.

@neolao
Created June 22, 2011 16:17
Show Gist options
  • Save neolao/1040463 to your computer and use it in GitHub Desktop.
Save neolao/1040463 to your computer and use it in GitHub Desktop.
/* Here we go, show the magazine */
$('#viewer').booklet({
width: bookWidth * 2,
height: bookHeight,
speed: 750,
pagePadding: 0,
pageNumbers: false,
closed: true,
autoCenter: true,
hash: false,
arrows: false,
manual: false,
hovers: false,
after: function(opts){
var fCountActual = parseInt(opts.curr);
if (fCountActual == 0){
fCountActual = opts.curr + 1;
window.location.hash = "/page/1";
}else if(fCountActual == MadMagzPagesCount){
fCountActual = opts.curr;
window.location.hash = "/page/" + opts.curr;
}else{
fCountActual = opts.curr+'-'+(opts.curr+1);
window.location.hash = "/page/" + opts.curr;
}
$('#fCountActual').empty().append(fCountActual);
}
});
/* Prepare functions for navigation */
lastHash = null;
function getHash(){
var windowHash = window.location.hash;
windowHash = windowHash.split('/');
return windowHash[2];
}
function updateBooklet()
{
var newHash = getHash();
if (newHash != lastHash) {
$('#viewer').booklet(parseInt(newHash));
}
}
$(window).bind("hashchange", updateBooklet);
updateBooklet();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment