From 92e2f47f18c850e36474497f3b6a72e2aaafd42c Mon Sep 17 00:00:00 2001 From: Bala Clark Date: Sat, 25 Dec 2010 09:44:57 +0100 Subject: [PATCH] enable the back button --- lib/ComicBook.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ComicBook.js b/lib/ComicBook.js index bf20176..958e239 100644 --- a/lib/ComicBook.js +++ b/lib/ComicBook.js @@ -66,7 +66,16 @@ function ComicBook(id, srcs, opts) { // the current page, can pass a default as a url hash var pointer = (parseInt(location.hash.substring(1),10) - 1) || 0; - + + // enables the back button by tracking any url hash changes and loading the correct page. + setInterval(function() { + var hash = parseInt(location.hash.substring(1),10) - 1; + if (hash !== pointer) { + pointer = hash; + ComicBook.prototype.draw(); + } + }, 300); + /** * Figure out the cursor position relative to the canvas. *