Skip to content

Commit

Permalink
Allow navigation within presenter window
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Kalb committed Oct 27, 2023
1 parent d170cb8 commit c093de1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 37 deletions.
30 changes: 15 additions & 15 deletions assets/js/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ export class Manager {
document.getElementById("slide-preview-" + data.current_page).scrollIntoView({
block: 'center',
behavior: 'smooth'
});
});
}, data.timeout ? data.timeout : 0)
}
})

window.addEventListener('keydown', (e) => {
if (e.target.tagName.toLowerCase() != "input") {

if ((e.target.tagName || '').toLowerCase() != "input") {
e.preventDefault()

switch (e.key) {
Expand All @@ -41,7 +41,7 @@ export class Manager {
case 'ArrowDown':
this.nextPage()
break
}
}
}
});
}
Expand All @@ -54,25 +54,25 @@ export class Manager {
document.getElementById("slide-preview-" + this.currentPage).scrollIntoView({
block: 'center',
behavior: 'smooth'
});
});
}
}

nextPage() {
if(this.currentPage == this.maxPage - 1)
return;
if (this.currentPage == this.maxPage - 1)
return;

this.currentPage += 1;
this.context.pushEventTo(this.context.el, "current-page", {"page": this.currentPage.toString()});
this.context.pushEventTo(this.context.el, "current-page", { "page": this.currentPage.toString() });
}

prevPage() {
if(this.currentPage == 0)
if (this.currentPage == 0)
return;

this.currentPage -= 1;
this.context.pushEventTo(this.context.el, "current-page", {"page": this.currentPage.toString()});
this.context.pushEventTo(this.context.el, "current-page", { "page": this.currentPage.toString() });

}
}

}
56 changes: 34 additions & 22 deletions assets/js/presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export class Presenter {
slideBy: 'page',
center: true,
autoplay: false,
controls: false,
controls: false,
swipeAngle: false,
startIndex: this.currentPage,
loop: false,
nav: false
nav: false
});

this.context.handleEvent('page', data => {
Expand Down Expand Up @@ -69,37 +69,49 @@ export class Presenter {
case 'f': // F
this.fullscreen()
break
}
case 'ArrowUp':
window.opener.dispatchEvent(new KeyboardEvent('keydown', { 'key': 'ArrowUp' }));
break
case 'ArrowLeft':
window.opener.dispatchEvent(new KeyboardEvent('keydown', { 'key': 'ArrowLeft' }));
break
case 'ArrowRight':
window.opener.dispatchEvent(new KeyboardEvent('keydown', { 'key': 'ArrowRight' }));
break
case 'ArrowDown':
window.opener.dispatchEvent(new KeyboardEvent('keydown', { 'key': 'ArrowDown' }));
break
}
}
});
}

fullscreen() {

var docEl = document.getElementById("presenter")
var docEl = document.getElementById("presenter")

try {
docEl.webkitRequestFullscreen()
.then(function() {
try {
docEl.webkitRequestFullscreen()
.then(function () {
})
.catch(function(error) {
.catch(function (error) {

});
} catch (e) {
docEl.requestFullscreen()
.then(function() {
} catch (e) {
docEl.requestFullscreen()
.then(function () {
})
.catch(function(error) {
.catch(function (error) {
});
docEl.mozRequestFullScreen()
.then(function() {

docEl.mozRequestFullScreen()
.then(function () {
})
.catch(function(error) {
.catch(function (error) {
});
}
}


}
}

}

0 comments on commit c093de1

Please sign in to comment.