don't lose the reading position after applying

enhancements.
This commit is contained in:
Bala Clark 2013-03-19 21:00:47 +01:00
parent 73752691a0
commit 5d20759dcc
2 changed files with 40 additions and 38 deletions

View file

@ -8,7 +8,6 @@
- trigger preload if requesting valid but not loaded images (can happen if network was interupted)
- loading and generally hackiness of pointer is buggy, fix.
- check for html5 feature support where used: diveintohtml5.org/everything.html or www.modernizr.com
- when applying enhancements reading position gets lost
- full browser test - IE9 / FF3.6+ / Chrome / Safari / Opera
- don't inlcude the closure compiler, expect it (or similar) to be installed instead
@ -542,7 +541,10 @@ function ComicBook(id, srcs, opts) {
/**
* Draw the current page in the canvas
*/
ComicBook.prototype.drawPage = function(page_no) {
ComicBook.prototype.drawPage = function(page_no, reset_scroll) {
var reset_scroll = (typeof reset_scroll !== "undefined") ? reset_scroll : true;
var scrollY = reset_scroll ? 0 : window.scrollY;
// if a specific page is given try to render it, if not bail and wait for preload() to render it
if (typeof page_no === "number" && page_no < srcs.length && page_no > 0) {
@ -690,7 +692,7 @@ function ComicBook(id, srcs, opts) {
}
// make sure the top of the page is in view
window.scroll(0, 0);
window.scroll(0, scrollY);
};
/**
@ -762,7 +764,7 @@ function ComicBook(id, srcs, opts) {
} else {
delete options.enhance[method];
}
ComicBook.prototype.drawPage();
ComicBook.prototype.drawPage(null, false);
},
/**
@ -812,7 +814,7 @@ function ComicBook(id, srcs, opts) {
*/
resaturate: function() {
delete options.enhance.desaturate;
ComicBook.prototype.drawPage();
ComicBook.prototype.drawPage(null, false);
},
/**
@ -840,7 +842,7 @@ function ComicBook(id, srcs, opts) {
desharpen: function() {
delete options.enhance.sharpen;
ComicBook.prototype.drawPage();
ComicBook.prototype.drawPage(null, false);
}
};