Commit a648e9ca authored by Vadim Makeev's avatar Vadim Makeev

Updates

parent ac099fb0
No preview for this file type
/** /**
* Core for Shower HTML presentation engine * Core for Shower HTML presentation engine
* @shower/core v3.0.0, https://github.com/shower/core * @shower/core v3.1.0, https://github.com/shower/core
* @copyright 2010–2021 Vadim Makeev, https://pepelsbey.net * @copyright 2010–2021 Vadim Makeev, https://pepelsbey.net
* @license MIT * @license MIT
*/ */
...@@ -561,6 +561,41 @@ ...@@ -561,6 +561,41 @@
window.addEventListener('resize', updateScale); window.addEventListener('resize', updateScale);
}; };
var touch = (shower) => {
let exitFullScreen = false;
let clickable = false;
document.addEventListener('touchstart', (event) => {
if (event.touches.length === 1) {
const touch = event.touches[0];
const x = touch.clientX;
const { target } = touch;
clickable = target.tabIndex !== -1;
if (!clickable) {
if (shower.isFullMode) {
if (event.cancelable) event.preventDefault();
if (window.innerWidth / 2 < x) {
shower.next();
} else {
shower.prev();
}
}
}
} else if (event.touches.length === 3) {
exitFullScreen = true;
}
});
shower.container.addEventListener('touchend', (event) => {
if (exitFullScreen) {
event.preventDefault();
exitFullScreen = false;
shower.exitFullMode();
} else if (event.touches.length === 1 && !clickable && shower.isFullMode)
event.preventDefault();
});
};
var installModules = (shower) => { var installModules = (shower) => {
a11y(shower); a11y(shower);
progress(shower); progress(shower);
...@@ -570,6 +605,7 @@ ...@@ -570,6 +605,7 @@
title(shower); title(shower);
location$1(shower); // should come after `title` location$1(shower); // should come after `title`
view(shower); view(shower);
touch(shower);
// maintains invariant: active slide always exists in `full` mode // maintains invariant: active slide always exists in `full` mode
if (shower.isFullMode && !shower.activeSlide) { if (shower.isFullMode && !shower.activeSlide) {
......
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