Fix #99: Inner navigation should be also controlled by slide timing
This commit is contained in:
parent
310f5d74c4
commit
e6833d5fbf
30
shower.js
30
shower.js
|
@ -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,21 +550,37 @@ 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) {
|
||||||
|
|
||||||
|
// 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.innerLength);
|
||||||
|
} else {
|
||||||
timer = setInterval(function() {
|
timer = setInterval(function() {
|
||||||
// Inner Navigation not finished
|
// Inner Navigation not finished
|
||||||
if (slide.innerLength >= slide.innerComplete) {
|
if (slide.innerLength > slide.innerComplete) {
|
||||||
shower.increaseInnerNavigation(slideNumber);
|
shower.increaseInnerNavigation(slideNumber);
|
||||||
slide.innerComplete++;
|
slide.innerComplete++;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
// Inner Navigation already finished
|
||||||
|
if (slide.innerLength === slide.innerComplete) {
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
// Check if last slide
|
// Check if last slide
|
||||||
if (slideList.length !== slideNumber + 1) {
|
if (slideList.length !== slideNumber + 1) {
|
||||||
|
@ -574,6 +590,7 @@ window.shower = (function(window, document, undefined) {
|
||||||
},
|
},
|
||||||
slide.timing);
|
slide.timing);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
@ -629,10 +646,13 @@ 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) {
|
||||||
|
|
Loading…
Reference in New Issue