Summary Files Commits Branches @commit @diff @stats
path: root / src / scripts
diff options
context:
space:
mode:
Commiteafd929a264bfc9891b011ed163b8bf59230179b (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-02-27 20:29:10 +0200
Committer
 Syndamia <kamen@syndamia.com>
2023-02-27 20:29:10 +0200
Filesff1253d206be5654f2375b5baff7210b55b54a9b /src/scripts
syndamia.com-eafd929a264bfc9891b011ed163b8bf59230179b.tar
syndamia.com-eafd929a264bfc9891b011ed163b8bf59230179b.tar.gz
syndamia.com-eafd929a264bfc9891b011ed163b8bf59230179b.zip
Parenteaac14baa439227641cc5a240ac15123db95af0b (diff)
[presentation] Added id to each slide, which also influences slideIndex var, holding ctrl will not activate any key combination, fixed slide size on print
1 files changed, 9 insertions, 4 deletions
-rw-r--r--src/scripts/presentation.js13
diff --git a/src/scripts/presentation.js b/src/scripts/presentation.js
index 10d3c59..d60e698 100644
--- a/src/scripts/presentation.js
+++ b/src/scripts/presentation.js
@@ -20,10 +20,14 @@ const prevSlideBtn = document.getElementById('prevSlideBtn');
const nextSlideBtn = document.getElementById('nextSlideBtn');
const slides = document.getElementsByClassName('slide');
-var slideIndex = 0;
+var presenting = false;
+var slideIndex = parseInt(document.URL.substr(document.URL.indexOf("#slide") + 7));
+if (isNaN(slideIndex)) slideIndex = 0;
// Shows the "slideIndex + mod" numbered slide
function showSlide(mod) {
+ if (!presenting) return;
+
slides[slideIndex].classList.remove('absolute-slide');
slideIndex = (slides.length + slideIndex + mod) % slides.length;
slides[slideIndex].classList.add('absolute-slide');
@@ -43,7 +47,6 @@ const presentCont = document.getElementById('presentCont');
const presentBtn = document.getElementById('presentBtn');
const articleBtn = document.getElementById('articleBtn');
-var presenting = false;
var pageY = 0;
var pageX = 0;
@@ -85,6 +88,8 @@ articleBtn.addEventListener('click', function() {
/* Keyboard controls */
document.addEventListener('keydown', function (e) {
+ if (e.ctrlKey) return;
+
switch (e.code) {
// Previous slide
case 'Backspace': case 'PageUp':
@@ -106,11 +111,11 @@ document.addEventListener('keydown', function (e) {
break;
// Go to first slide
case 'Home':
- if (presenting) showSlide(-slideIndex);
+ showSlide(-slideIndex);
break;
// Go to last slide
case 'End':
- if (presenting) showSlide(-slideIndex -1);
+ showSlide(-slideIndex -1);
break;
}
});