Fix #99: Inner navigation should be also controlled by slide timing

This commit is contained in:
miripiruni 2013-02-13 00:00:03 +04:00
parent 310f5d74c4
commit e6833d5fbf
1 changed files with 33 additions and 13 deletions

View File

@ -48,7 +48,7 @@ window.shower = (function(window, document, undefined) {
id : slides[i].id, id : slides[i].id,
hasInnerNavigation : null !== slides[i].querySelector('.next'), hasInnerNavigation : null !== slides[i].querySelector('.next'),
timing : timing, timing : timing,
innerLength : slides[i].querySelectorAll('.next').length, innerLength : slides[i].querySelectorAll('.next').length + 1,
innerComplete : 0 innerComplete : 0
}); });
} }
@ -550,29 +550,46 @@ window.shower = (function(window, document, undefined) {
var slide; var slide;
slideNumber = shower._normalizeSlideNumber(slideNumber); slideNumber = shower._normalizeSlideNumber(slideNumber);
slide = slideList[slideNumber];
if ( ! shower._isNumber(slideNumber)) { if ( ! shower._isNumber(slideNumber)) {
throw new Error('Gimme slide number as Number, baby!'); throw new Error('Gimme slide number as Number, baby!');
} }
slide = slideList[slideNumber];
clearInterval(timer); clearInterval(timer);
if (slide && slide.timing) { if (slide && slide.timing) {
timer = setInterval(function() {
// Inner Navigation not finished // Inner Navigation already finished
if (slide.innerLength >= slide.innerComplete) { if (slide.innerLength === slide.innerComplete) {
shower.increaseInnerNavigation(slideNumber); timer = setInterval(function() {
slide.innerComplete++;
} else {
clearInterval(timer); clearInterval(timer);
// Check if last slide // Check if last slide
if (slideList.length !== slideNumber + 1) { if (slideList.length !== slideNumber + 1) {
shower.next(); shower.next();
} }
} },
}, slide.timing * slide.innerLength);
slide.timing); } 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; return true;
@ -629,11 +646,14 @@ window.shower = (function(window, document, undefined) {
}, false); }, false);
document.addEventListener('keydown', function(e) { document.addEventListener('keydown', function(e) {
var currentSlideNumber,
isInnerNavCompleted;
// Shortcut for alt, ctrl and meta keys // Shortcut for alt, ctrl and meta keys
if (e.altKey || e.ctrlKey || e.metaKey) { return; } if (e.altKey || e.ctrlKey || e.metaKey) { return; }
var currentSlideNumber = shower.getCurrentSlideNumber(), currentSlideNumber = shower.getCurrentSlideNumber(),
isInnerNavCompleted = true; isInnerNavCompleted = true;
switch (e.which) { switch (e.which) {
case 116: // F5 case 116: // F5