@@ -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
0 commit comments