Skip to content

Commit

Permalink
Check if the page is scrolled when using spacebar in reader (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
Difegue committed Oct 19, 2018
1 parent ccb0d13 commit 8b97094
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions public/js/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ function moveSomething(e) {
break;
case 32:
// spacebar pressed
advancePage(1);
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
window.scrollTo(0, 0);
advancePage(1);
}
break;
case 39:
// right key pressed
Expand All @@ -31,7 +34,7 @@ function toastHelpReader() {

$.toast({
heading: 'Navigation Help',
text: 'You can navigate between pages using : <ul><li> The arrow icons</li> <li>Your keyboard arrows</li> <li> Touching the left/right side of the image.</li></ul><br> To return to the archive index, touch the arrow pointing down.<br> Pressing CTRL will bring up the pages overlay.',
text: 'You can navigate between pages using : <ul><li> The arrow icons</li> <li>Your keyboard arrows (and the spacebar)</li> <li> Touching the left/right side of the image.</li></ul><br> To return to the archive index, touch the arrow pointing down.<br> Pressing CTRL will bring up the pages overlay.',
hideAfter: false,
position: 'top-left',
icon: 'info'
Expand Down Expand Up @@ -95,7 +98,7 @@ function updateImageMap() {
function goToPage(page) {

previousPage = currentPage;

if (page < 0)
currentPage = 0;
else if (page >= pageNumber)
Expand Down Expand Up @@ -225,13 +228,13 @@ function canvasCallback() {

//If w > h on one of the images, set canvasdata to the first image only
if (img1.naturalWidth > img1.naturalHeight || img2.naturalWidth > img2.naturalHeight) {

//Depending on whether we were going forward or backward, display img1 or img2
if (previousPage > currentPage)
$("#img").attr("src", img2.src);
else
$("#img").attr("src", img1.src);

showingSinglePage = true;
imagesLoaded = 0;
return;
Expand Down

0 comments on commit 8b97094

Please sign in to comment.