Commit 54a2d333 authored by Vadim Makeev's avatar Vadim Makeev

basic support for touch devices; fixed bug with mobile safari

parent 25b9ac09
......@@ -80,6 +80,23 @@
updateProgress(slide_number);
}
}
function dispatchSingleSlideMode(e) {
if (
'SECTION' === e.target.nodeName &&
-1 !== e.target.parentNode.parentNode.className.indexOf('slide') &&
isSlideListMode()
) {
e.preventDefault();
// NOTE: we should update hash to get things work properly
url.hash = '#' + e.target.parentNode.parentNode.id;
history.replaceState(null, null, url.pathname + '?full#' + e.target.parentNode.parentNode.id);
enterSingleSlideMode();
updateProgress(getCurrentSlideNumber());
}
}
window.addEventListener('DOMContentLoaded', function () {
if (!isSlideListMode()) {
......@@ -193,20 +210,25 @@
}
}, false);
document.addEventListener('click', function (e) {
if (
'SECTION' === e.target.nodeName &&
-1 !== e.target.parentNode.parentNode.className.indexOf('slide') &&
isSlideListMode()
) {
e.preventDefault();
document.addEventListener('click', dispatchSingleSlideMode, false);
document.addEventListener('touchend', dispatchSingleSlideMode, false);
// NOTE: we should update hash to get things work properly
url.hash = '#' + e.target.parentNode.parentNode.id;
history.replaceState(null, null, url.pathname + '?full#' + e.target.parentNode.parentNode.id);
enterSingleSlideMode();
document.addEventListener('touchstart', function (e) {
if(!isSlideListMode()) {
var current_slide_number = getCurrentSlideNumber(),
x = e.touches[0].pageX;
if (x > window.innerWidth/2) {
current_slide_number++;
} else {
current_slide_number--;
}
goToSlide(current_slide_number);
}
}, false);
updateProgress(getCurrentSlideNumber());
document.addEventListener('touchmove', function (e) {
if(!isSlideListMode()) {
e.preventDefault();
}
}, false);
......
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