Skip to content

Commit df2a241

Browse files
committed
feat: code by Trae
1 parent 8b5b921 commit df2a241

2 files changed

Lines changed: 35 additions & 10 deletions

File tree

epub_browser/assets/chapter.js

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -988,17 +988,42 @@ function initScript() {
988988
function handleClickPage(e) {
989989
if (!isClickPageEnabled || !isPaginationMode) return;
990990

991+
// 排除一些特殊元素,避免误触发
992+
const target = e.target;
993+
const tagName = target.tagName.toLowerCase();
994+
const isInteractiveElement =
995+
tagName === 'a' ||
996+
tagName === 'button' ||
997+
tagName === 'input' ||
998+
tagName === 'textarea' ||
999+
tagName === 'select' ||
1000+
target.closest('a') ||
1001+
target.closest('button') ||
1002+
target.closest('input') ||
1003+
target.closest('textarea') ||
1004+
target.closest('select') ||
1005+
target.closest('.navigation') ||
1006+
target.closest('.font-controls') ||
1007+
target.closest('.reading-controls') ||
1008+
target.closest('.toc-container');
1009+
1010+
if (isInteractiveElement) return;
1011+
9911012
const screenWidth = window.innerWidth;
992-
const targetArea = screenWidth * 0.2;
1013+
const leftArea = screenWidth * 0.3; // 左侧30%区域
1014+
const rightArea = screenWidth * 0.7; // 右侧30%区域(从70%开始)
9931015

994-
// 左侧20%区域点击
995-
if (e.clientX < targetArea) {
1016+
// 左侧30%区域点击 - 上一页
1017+
if (e.clientX < leftArea) {
1018+
e.preventDefault();
9961019
prevPageBtn.click();
9971020
}
998-
// 右侧20%区域点击
999-
else if (e.clientX > screenWidth - targetArea) {
1021+
// 右侧30%区域点击 - 下一页
1022+
else if (e.clientX > rightArea) {
1023+
e.preventDefault();
10001024
nextPageBtn.click();
10011025
}
1026+
// 中间40%区域不触发翻页
10021027
}
10031028

10041029
// 初始化点击翻页功能状态
@@ -1042,8 +1067,8 @@ function initScript() {
10421067
// 初始化点击翻页功能状态
10431068
initClickPageState();
10441069

1045-
// 监听点击事件
1046-
content.addEventListener('click', handleClickPage);
1070+
// 监听整个 body 的点击事件
1071+
document.body.addEventListener('click', handleClickPage);
10471072

10481073
// 点击翻页按钮点击事件
10491074
toggleClickPageBtn.addEventListener('click', function() {
@@ -1052,9 +1077,9 @@ function initScript() {
10521077
updateClickPageButton();
10531078

10541079
if (isClickPageEnabled) {
1055-
showNotification('Click to turn page enabled', 'info');
1080+
showNotification('Click edge to turn page enabled', 'info');
10561081
} else {
1057-
showNotification('Click to turn page disabled', 'info');
1082+
showNotification('Click edge to turn page disabled', 'info');
10581083
}
10591084
});
10601085

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name="epub-browser", # 在PyPI上显示的项目名称
9-
version="1.7.4", # 初始版本号
9+
version="1.7.5", # 初始版本号
1010
author="dfface", # 作者名
1111
author_email="dfface@sina.com", # 作者邮箱
1212
keywords="epub reader html export browser convert calibre-web calibre kindle web server local",

0 commit comments

Comments
 (0)