Skip to content

Commit

Permalink
add: defaultImgScaleModeC option #126;
Browse files Browse the repository at this point in the history
  • Loading branch information
MapoMagpie committed Jan 26, 2025
1 parent 1e69409 commit 5943bd8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
7 changes: 4 additions & 3 deletions eh-view-enhance.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,7 @@ Reporta problemas aquí: <a target='_blank' href='https://github.com/MapoMagpie/
pageHelperAbBottom: "20px",
pageHelperAbRight: "unset",
imgScale: 100,
defaultImgScaleModeC: 60,
autoPageSpeed: 5,
// pagination readmode = 5, continuous readmode = 1
autoPlay: false,
Expand Down Expand Up @@ -1310,7 +1311,7 @@ Reporta problemas aquí: <a target='_blank' href='https://github.com/MapoMagpie/
changed = true;
}
if (cf.imgScale === void 0 || isNaN(cf.imgScale) || cf.imgScale === 0) {
cf.imgScale = cf.readMode === "continuous" ? 80 : 100;
cf.imgScale = cf.readMode === "continuous" ? cf.defaultImgScaleModeC : 100;
changed = true;
}
const newCf = patchConfig(cf);
Expand Down Expand Up @@ -10133,7 +10134,7 @@ ${chapters.map((c, i) => `<div><label>
q("#paginationInput", HTML.pageHelper).addEventListener("wheel", (event) => events.modNumberConfigEvent("paginationIMGCount", event.deltaY < 0 ? "add" : "minus"));
q("#scaleInput", HTML.pageHelper).addEventListener("mousedown", (event) => {
const element = event.target;
const scale = conf.imgScale || (conf.readMode === "continuous" ? 80 : 100);
const scale = conf.imgScale || (conf.readMode === "continuous" ? conf.defaultImgScaleModeC : 100);
dragElementWithLine(event, element, { y: true }, (data) => {
if (data.distance === 0) return;
const fix = (data.direction & 3) === 1 ? 1 : -1;
Expand Down Expand Up @@ -11258,7 +11259,7 @@ ${chapters.map((c, i) => `<div><label>
return newPercent;
}
resetScaleBigImages(syncConf) {
const percent = conf.readMode !== "continuous" || IS_MOBILE ? 100 : 80;
const percent = conf.readMode !== "continuous" || IS_MOBILE ? 100 : conf.defaultImgScaleModeC;
this.scaleBigImages(1, 0, percent, syncConf);
}
flushLoadingHelper() {
Expand Down
5 changes: 4 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export type Config = {
pageHelperAbRight: string
/** 图片缩放比例 eg: 80, means 80% */
imgScale: number
/** 默认图片缩放比例,仅限连续阅读模式下。*/
defaultImgScaleModeC: number
/** 自动翻页间隔 */
autoPageSpeed: number
/** 自动开始 */
Expand Down Expand Up @@ -143,6 +145,7 @@ function defaultConf(): Config {
pageHelperAbBottom: "20px",
pageHelperAbRight: "unset",
imgScale: 100,
defaultImgScaleModeC: 60,
autoPageSpeed: 5, // pagination readmode = 5, continuous readmode = 1
autoPlay: false,
hdThumbnails: false,
Expand Down Expand Up @@ -251,7 +254,7 @@ function confHealthCheck(cf: Config): Config {
changed = true;
}
if (cf.imgScale === undefined || isNaN(cf.imgScale) || cf.imgScale === 0) {
cf.imgScale = cf.readMode === "continuous" ? 80 : 100;
cf.imgScale = cf.readMode === "continuous" ? cf.defaultImgScaleModeC : 100;
changed = true;
}
const newCf = patchConfig(cf);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/big-image-frame-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ export class BigImageFrameManager {
}

resetScaleBigImages(syncConf: boolean) {
const percent = (conf.readMode !== "continuous" || IS_MOBILE) ? 100 : 80;
const percent = (conf.readMode !== "continuous" || IS_MOBILE) ? 100 : conf.defaultImgScaleModeC;
this.scaleBigImages(1, 0, percent, syncConf);
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export function addEventListeners(events: Events, HTML: Elements, BIFM: BigImage

q("#scaleInput", HTML.pageHelper).addEventListener("mousedown", (event) => {
const element = event.target as HTMLElement;
const scale = conf.imgScale || (conf.readMode === "continuous" ? 80 : 100);
const scale = conf.imgScale || (conf.readMode === "continuous" ? conf.defaultImgScaleModeC : 100);
dragElementWithLine(event, element, { y: true }, (data) => {
if (data.distance === 0) return;
const fix = (data.direction & 3) === 1 ? 1 : -1; // 4bit: UDLR, data.direction & 3 means remove UD
Expand Down
2 changes: 1 addition & 1 deletion src/ui/style-custom-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function stylePreset(index: number) {
.bifm-container > div {
border: 2px solid green;
}
/*`,
*/`,
`.ehvp-root {
--ehvp-theme-bg-color: #ffffff;
--ehvp-theme-font-color: #760098;
Expand Down

0 comments on commit 5943bd8

Please sign in to comment.