Commit 6bf9219b authored by Oleg Roschupkin's avatar Oleg Roschupkin

Fix bug with Enter when no slide is active.

Closes issue #56.
parent b9bf251d
...@@ -53,10 +53,10 @@ ...@@ -53,10 +53,10 @@
return -1; return -1;
} }
function scrollToCurrentSlide() { function scrollToSlide(slideNumber) {
var currentSlide = document.getElementById( if (-1 === slideNumber ) { return; }
slideList[getCurrentSlideNumber()].id
); var currentSlide = document.getElementById(slideList[slideNumber].id);
if (null != currentSlide) { if (null != currentSlide) {
window.scrollTo(0, currentSlide.offsetTop); window.scrollTo(0, currentSlide.offsetTop);
...@@ -156,7 +156,7 @@ ...@@ -156,7 +156,7 @@
window.addEventListener('popstate', function (e) { window.addEventListener('popstate', function (e) {
if (isListMode()) { if (isListMode()) {
enterListMode(); enterListMode();
scrollToCurrentSlide(); scrollToSlide(getCurrentSlideNumber());
} else { } else {
enterSlideMode(); enterSlideMode();
} }
...@@ -177,7 +177,7 @@ ...@@ -177,7 +177,7 @@
switch (e.which) { switch (e.which) {
case 116: // F5 case 116: // F5
case 13: // Enter case 13: // Enter
if (isListMode()) { if (isListMode() && -1 !== currentSlideNumber) {
e.preventDefault(); e.preventDefault();
history.pushState(null, null, url.pathname + '?full' + getSlideHash(currentSlideNumber)); history.pushState(null, null, url.pathname + '?full' + getSlideHash(currentSlideNumber));
...@@ -193,7 +193,7 @@ ...@@ -193,7 +193,7 @@
history.pushState(null, null, url.pathname + getSlideHash(currentSlideNumber)); history.pushState(null, null, url.pathname + getSlideHash(currentSlideNumber));
enterListMode(); enterListMode();
scrollToCurrentSlide(); scrollToSlide(currentSlideNumber);
} }
break; break;
...@@ -217,7 +217,9 @@ ...@@ -217,7 +217,9 @@
// Only go to next slide if current slide have no inner // Only go to next slide if current slide have no inner
// navigation or inner navigation is fully shown // navigation or inner navigation is fully shown
// NOTE: But first of all check if there is no current slide
if ( if (
-1 === currentSlideNumber ||
!slideList[currentSlideNumber].hasInnerNavigation || !slideList[currentSlideNumber].hasInnerNavigation ||
-1 === increaseInnerNavigation(currentSlideNumber) -1 === increaseInnerNavigation(currentSlideNumber)
) { ) {
...@@ -276,4 +278,4 @@ ...@@ -276,4 +278,4 @@
} }
}, false); }, false);
}()); }());
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment