From e6833d5fbf011684f35931bcb2148209c7aba7cd Mon Sep 17 00:00:00 2001 From: miripiruni Date: Wed, 13 Feb 2013 00:00:03 +0400 Subject: [PATCH] Fix #99: Inner navigation should be also controlled by slide timing --- shower.js | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/shower.js b/shower.js index c332f09..2e28c69 100755 --- a/shower.js +++ b/shower.js @@ -48,7 +48,7 @@ window.shower = (function(window, document, undefined) { id : slides[i].id, hasInnerNavigation : null !== slides[i].querySelector('.next'), timing : timing, - innerLength : slides[i].querySelectorAll('.next').length, + innerLength : slides[i].querySelectorAll('.next').length + 1, innerComplete : 0 }); } @@ -550,29 +550,46 @@ window.shower = (function(window, document, undefined) { var slide; slideNumber = shower._normalizeSlideNumber(slideNumber); - slide = slideList[slideNumber]; if ( ! shower._isNumber(slideNumber)) { throw new Error('Gimme slide number as Number, baby!'); } + slide = slideList[slideNumber]; + clearInterval(timer); if (slide && slide.timing) { - timer = setInterval(function() { - // Inner Navigation not finished - if (slide.innerLength >= slide.innerComplete) { - shower.increaseInnerNavigation(slideNumber); - slide.innerComplete++; - } else { + + // Inner Navigation already finished + if (slide.innerLength === slide.innerComplete) { + timer = setInterval(function() { clearInterval(timer); // Check if last slide if (slideList.length !== slideNumber + 1) { shower.next(); } - } - }, - slide.timing); + }, + slide.timing * slide.innerLength); + } else { + timer = setInterval(function() { + // Inner Navigation not finished + if (slide.innerLength > slide.innerComplete) { + shower.increaseInnerNavigation(slideNumber); + slide.innerComplete++; + } + + // Inner Navigation already finished + if (slide.innerLength === slide.innerComplete) { + clearInterval(timer); + // Check if last slide + if (slideList.length !== slideNumber + 1) { + shower.next(); + } + } + }, + slide.timing); + } } return true; @@ -629,11 +646,14 @@ window.shower = (function(window, document, undefined) { }, false); document.addEventListener('keydown', function(e) { + var currentSlideNumber, + isInnerNavCompleted; + // Shortcut for alt, ctrl and meta keys if (e.altKey || e.ctrlKey || e.metaKey) { return; } - var currentSlideNumber = shower.getCurrentSlideNumber(), - isInnerNavCompleted = true; + currentSlideNumber = shower.getCurrentSlideNumber(), + isInnerNavCompleted = true; switch (e.which) { case 116: // F5