Skip to content

Commit

Permalink
Fix bug where we would not check if there was actually a page to navi…
Browse files Browse the repository at this point in the history
…gate to when using arrow keys
  • Loading branch information
azerupi committed Dec 30, 2015
1 parent 98cd2f0 commit ae6334f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/theme/book.js
Expand Up @@ -32,11 +32,15 @@ $( document ).ready(function() {
switch (e.keyCode) {
case KEY_CODES.NEXT_KEY:
e.preventDefault();
window.location.href = $('.nav-chapters.next').attr('href');
if($('.nav-chapters.next').length) {
window.location.href = $('.nav-chapters.next').attr('href');
}
break;
case KEY_CODES.PREVIOUS_KEY:
e.preventDefault();
window.location.href = $('.nav-chapters.previous').attr('href');
if($('.nav-chapters.previous').length) {
window.location.href = $('.nav-chapters.previous').attr('href');
}
break;
}
});
Expand Down

0 comments on commit ae6334f

Please sign in to comment.