basic support for touch devices; fixed bug with mobile safari
This commit is contained in:
parent
25b9ac098d
commit
54a2d33367
|
@ -80,6 +80,23 @@
|
||||||
updateProgress(slide_number);
|
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 () {
|
window.addEventListener('DOMContentLoaded', function () {
|
||||||
if (!isSlideListMode()) {
|
if (!isSlideListMode()) {
|
||||||
|
@ -193,20 +210,25 @@
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
document.addEventListener('click', function (e) {
|
document.addEventListener('click', dispatchSingleSlideMode, false);
|
||||||
if (
|
document.addEventListener('touchend', dispatchSingleSlideMode, false);
|
||||||
'SECTION' === e.target.nodeName &&
|
|
||||||
-1 !== e.target.parentNode.parentNode.className.indexOf('slide') &&
|
document.addEventListener('touchstart', function (e) {
|
||||||
isSlideListMode()
|
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);
|
||||||
|
|
||||||
|
document.addEventListener('touchmove', function (e) {
|
||||||
|
if(!isSlideListMode()) {
|
||||||
e.preventDefault();
|
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());
|
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue