Commit ce5a4178 authored by Vadim Makeev's avatar Vadim Makeev

currentSlide function added

parent 5481f4f0
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
} }
function turnSlide(e) { function turnSlide(e) {
var current = slideList.indexOf(url.hash.substr(1)), target; var current = currentSlide(), target;
if(e) { if(e) {
if(e.type == 'keydown') { if(e.type == 'keydown') {
var prevent = true; var prevent = true;
...@@ -104,21 +104,24 @@ ...@@ -104,21 +104,24 @@
function isFull() { function isFull() {
return url.search.substr(1) == 'full'; return url.search.substr(1) == 'full';
} }
function currentSlide() {
return slideList.indexOf(url.hash.substr(1));
}
function updateProgress() { function updateProgress() {
if(!progress) return; if(!progress) return;
progress.style.width = (100/(slideList.length-1) * slideList.indexOf(url.hash.substr(1))).toFixed(2) + '%'; progress.style.width = (100/(slideList.length-1) * currentSlide()).toFixed(2) + '%';
} }
window.addEventListener('DOMContentLoaded', function() { window.addEventListener('DOMContentLoaded', function() {
if(isFull()) enterFull(); if(isFull()) enterFull();
}, false); }, false);
window.addEventListener("popstate", function() { window.addEventListener('popstate', function() {
var current_slide_number = slideList.indexOf(url.hash.substr(1)); if(-1 === currentSlide()) exitFull();
if (-1 === current_slide_number) { exitFull(); }
}, false); }, false);
document.addEventListener('keydown', turnSlide, false); document.addEventListener('keydown', turnSlide, false);
document.addEventListener('keydown', enterFullKey, false); document.addEventListener('keydown', enterFullKey, 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