This commit is contained in:
Курнат Андрей
2026-02-14 20:36:25 +03:00
parent d6ba23a8ef
commit 6c18e0526b

View File

@@ -101,6 +101,28 @@
z-index: 9999;
display: none;
}
/* Прозрачные зоны для тачей поверх всего */
#touch-left, #touch-right, #touch-center {
position: fixed;
top: 0;
height: 100%;
z-index: 9000;
}
#touch-left {
left: 0;
width: 30%;
}
#touch-right {
right: 0;
width: 30%;
}
#touch-center {
left: 30%;
width: 40%;
}
</style>
</head>
<body>
@@ -116,7 +138,10 @@
<span id="error-text"></span>
</div>
</div>
<div id="debug-log"></div>
<!-- Невидимые зоны тачей поверх iframe epub.js -->
<div id="touch-left"></div>
<div id="touch-center"></div>
<div id="touch-right"></div>
<script src="_framework/hybridwebview.js"></script>
<script>
// ========== DEBUG LOGGING ==========
@@ -154,47 +179,53 @@
}
}
// ========== SWIPE DETECTION ==========
var touchStartX = 0;
var touchStartY = 0;
var touchStartTime = 0;
var SWIPE_THRESHOLD = 50;
var SWIPE_TIME_LIMIT = 500;
document.addEventListener('touchstart', function (e) {
touchStartX = e.changedTouches[0].clientX;
touchStartY = e.changedTouches[0].clientY;
touchStartTime = Date.now();
}, { passive: true });
document.addEventListener('touchend', function (e) {
var touchEndX = e.changedTouches[0].clientX;
var touchEndY = e.changedTouches[0].clientY;
var elapsed = Date.now() - touchStartTime;
if (elapsed > SWIPE_TIME_LIMIT) return;
var diffX = touchEndX - touchStartX;
var diffY = touchEndY - touchStartY;
if (Math.abs(diffX) > Math.abs(diffY) && Math.abs(diffX) > SWIPE_THRESHOLD) {
if (diffX < 0) {
nextPage();
} else {
// ========== TOUCH ZONES ==========
document.getElementById('touch-left').addEventListener('click', function (e) {
e.preventDefault();
e.stopPropagation();
prevPage();
}
} else if (Math.abs(diffX) < 15 && Math.abs(diffY) < 15) {
var screenWidth = window.innerWidth;
if (touchStartX > screenWidth * 0.3 && touchStartX < screenWidth * 0.7) {
});
document.getElementById('touch-right').addEventListener('click', function (e) {
e.preventDefault();
e.stopPropagation();
nextPage();
});
document.getElementById('touch-center').addEventListener('click', function (e) {
e.preventDefault();
e.stopPropagation();
sendMessage('toggleMenu', {});
} else if (touchStartX <= screenWidth * 0.3) {
prevPage();
} else {
nextPage();
}
}
}, { passive: true });
});
// Свайпы на зонах
var swipeStartX = 0, swipeStartY = 0, swipeStartTime = 0;
function onSwipeStart(e) {
var touch = e.touches ? e.touches[0] : e;
swipeStartX = touch.clientX;
swipeStartY = touch.clientY;
swipeStartTime = Date.now();
}
function onSwipeEnd(e) {
var touch = e.changedTouches ? e.changedTouches[0] : e;
var dx = touch.clientX - swipeStartX;
var dy = touch.clientY - swipeStartY;
var dt = Date.now() - swipeStartTime;
if (dt > 500) return;
if (Math.abs(dx) > Math.abs(dy) && Math.abs(dx) > 50) {
if (dx < 0) nextPage();
else prevPage();
}
}
['touch-left', 'touch-center', 'touch-right'].forEach(function (id) {
var el = document.getElementById(id);
el.addEventListener('touchstart', onSwipeStart, { passive: true });
el.addEventListener('touchend', onSwipeEnd, { passive: true });
});
// ========== EPUB READER ==========
var book = null;
var rendition = null;
@@ -266,7 +297,6 @@
spread: 'none',
flow: 'paginated'
});
rendition.themes.default({
'body': {
'font-family': 'serif !important',