Skip to content

Commit 2b80ad4

Browse files
committed
feat: ✨ 增加「启用菜单区域」设置项,以便禁用点击中间唤出菜单功能
https://sleazyfork.org/scripts/comicread/discussions/308707
1 parent 09c31de commit 2b80ad4

10 files changed

Lines changed: 39 additions & 23 deletions

File tree

locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
"dir_ltr": "LTR (American comics)",
145145
"dir_rtl": "RTL (Japanese manga)",
146146
"disable_auto_enlarge": "Disable automatic image enlarge",
147+
"enable_menu": "Enable menu area",
147148
"first_page_fill": "Enable first page fill by default",
148149
"fit_to_width": "Fit to width",
149150
"img_recognition": "Image Recognition",

locales/hu.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
"dir_ltr": "从左到右(美漫)",
145145
"dir_rtl": "从右到左(日漫)",
146146
"disable_auto_enlarge": "禁止图片自动放大",
147+
"enable_menu": "Menüterület engedélyezése",
147148
"first_page_fill": "默认启用首页填充",
148149
"fit_to_width": "图片适合宽度",
149150
"img_recognition": "图像识别",

locales/ru.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
"dir_ltr": "Чтение слева направо (Американские комиксы)",
145145
"dir_rtl": "Чтение справа налево (Японская манга)",
146146
"disable_auto_enlarge": "Отключить автоматическое масштабирование изображений",
147+
"enable_menu": "Включить область меню",
147148
"first_page_fill": "Включить заполнение первой страницы по умолчанию",
148149
"fit_to_width": "По ширине",
149150
"img_recognition": "распознавание изображений",

locales/ta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
"dir_ltr": "இடமிருந்து வலமாக (மெய் மேன்)",
145145
"dir_rtl": "வலமிருந்து இடமாக (ரிமான்)",
146146
"disable_auto_enlarge": "தடைசெய்யப்பட்ட படங்கள் தானாக விரிவாக்கப்படுகின்றன",
147+
"enable_menu": "மெனு பகுதியை இயக்கு",
147148
"first_page_fill": "இயல்பாக, முகப்புப்பக்க நிரப்புதலை இயக்கவும்",
148149
"fit_to_width": "அகலத்திற்கு ஏற்ற படம்",
149150
"img_recognition": "பட ஏற்பு",

locales/zh.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
"dir_ltr": "从左到右(美漫)",
145145
"dir_rtl": "从右到左(日漫)",
146146
"disable_auto_enlarge": "禁止图片自动放大",
147+
"enable_menu": "启用菜单区域",
147148
"first_page_fill": "默认启用首页填充",
148149
"fit_to_width": "图片适合宽度",
149150
"img_recognition": "图像识别",

src/components/Manga/actions/pointer.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const findClickEle = (
2424
for (const e of eleList) {
2525
const rect = e.getBoundingClientRect();
2626
if (inRange(rect.left, x, rect.right) && inRange(rect.top, y, rect.bottom))
27-
return e;
27+
return e as HTMLElement;
2828
}
2929
};
3030

@@ -40,7 +40,7 @@ const handlePageClick = (e: MouseEvent) => {
4040
}
4141

4242
const targetArea = findClickEle(refs.touchArea.children, e);
43-
if (!targetArea) return;
43+
if (!targetArea || targetArea.style.visibility === 'hidden') return;
4444
const areaName = (targetArea as HTMLElement).dataset.area as Area | undefined;
4545
if (!areaName) return;
4646

@@ -50,8 +50,6 @@ const handlePageClick = (e: MouseEvent) => {
5050
state.show.toolbar = !state.show.toolbar;
5151
});
5252

53-
if (!store.option.clickPageTurn.enabled || store.option.zoom.ratio !== 100)
54-
return;
5553
setState((state) => {
5654
resetUI(state);
5755

src/components/Manga/components/TouchArea.module.css

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
opacity: 1;
2525
}
2626

27-
& .touchArea {
27+
.touchArea {
2828
display: flex;
2929
align-items: center;
3030
justify-content: center;
@@ -63,26 +63,17 @@
6363
}
6464
}
6565

66-
.touchAreaRoot:not([data-turn-page]) {
67-
& .touchArea[data-area='next'],
68-
& .touchArea[data-area='NEXT'],
69-
& .touchArea[data-area='prev'],
70-
& .touchArea[data-area='PREV'] {
71-
visibility: hidden;
72-
}
73-
}
74-
7566
.touchAreaRoot[data-area='edge'] {
7667
grid-template-columns: 1fr min(30%, 10em) 1fr;
7768
}
7869

7970
.root[data-mobile] {
80-
& .touchAreaRoot {
71+
.touchAreaRoot {
8172
flex-direction: column !important;
8273
letter-spacing: 0;
8374
}
8475

85-
& [data-area]::after {
76+
[data-area]::after {
8677
font-size: 0.8em;
8778
}
8879
}

src/components/Manga/components/TouchArea.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,35 @@ export const dir = createRootMemo(() => {
4747
return store.option.dir === 'rtl' ? 'ltr' : 'rtl';
4848
});
4949

50+
const isShowArea = (area: Area) => {
51+
switch (area) {
52+
case 'PREV':
53+
case 'prev':
54+
case 'NEXT':
55+
case 'next':
56+
return store.option.clickPageTurn.enabled;
57+
58+
case 'MENU':
59+
case 'menu':
60+
return store.option.clickPageTurn.enableMenu;
61+
}
62+
};
63+
5064
export const TouchArea: Component = () => (
5165
<div
5266
ref={bindRef('touchArea')}
5367
class={classes.touchAreaRoot}
5468
dir={dir()}
5569
data-show={boolDataVal(store.show.touchArea)}
5670
data-area={areaType()}
57-
data-turn-page={boolDataVal(store.option.clickPageTurn.enabled)}
5871
>
5972
<For each={areaArrayMap[areaType()]}>
6073
{(rows) => (
6174
<For each={rows}>
6275
{(area) => (
6376
<div
6477
class={classes.touchArea}
78+
style={{ visibility: isShowArea(area) ? undefined : 'hidden' }}
6579
data-area={area}
6680
role="button"
6781
tabIndex={-1}

src/components/Manga/defaultSettingList.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,18 @@ export const defaultSettingList: () => SettingList = () => [
263263
name={t('other.enabled')}
264264
{...bindOption('clickPageTurn', 'enabled')}
265265
/>
266+
267+
<SettingsItemSwitch
268+
name={t('setting.option.show_clickable_area')}
269+
value={store.show.touchArea}
270+
onChange={() => setState('show', 'touchArea', !store.show.touchArea)}
271+
/>
272+
273+
<SettingsItemSwitch
274+
name={t('setting.option.enable_menu')}
275+
{...bindOption('clickPageTurn', 'enableMenu')}
276+
/>
277+
266278
<SettingsShowItem when={store.option.clickPageTurn.enabled}>
267279
<SettingsItemSelect
268280
name={t('setting.option.click_page_turn_area')}
@@ -276,12 +288,6 @@ export const defaultSettingList: () => SettingList = () => [
276288
{...bindOption('clickPageTurn', 'reverse')}
277289
/>
278290
</SettingsShowItem>
279-
280-
<SettingsItemSwitch
281-
name={t('setting.option.show_clickable_area')}
282-
value={store.show.touchArea}
283-
onChange={() => setState('show', 'touchArea', !store.show.touchArea)}
284-
/>
285291
</>
286292
),
287293
],

src/components/Manga/store/option.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export type Option = {
5858
enabled: boolean;
5959
/** 左右反转点击区域 */
6060
reverse: boolean;
61+
enableMenu: boolean;
6162
/** 区域排列类型 */
6263
area: keyof typeof areaArrayMap;
6364
};
@@ -139,6 +140,7 @@ const _defaultOption: Readonly<Option> = {
139140
enabled: 'ontouchstart' in document.documentElement,
140141
reverse: false,
141142
area: 'left_right',
143+
enableMenu: true,
142144
},
143145
firstPageFill: true,
144146
disableZoom: false,

0 commit comments

Comments
 (0)