Skip to content

Commit

Permalink
Merge pull request #774 from d-i-t-a/develop
Browse files Browse the repository at this point in the history
2.4.4
  • Loading branch information
aferditamuriqi authored Feb 7, 2024
2 parents ca0e267 + 920f0c6 commit 1413711
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@d-i-t-a/reader",
"version": "2.4.3",
"version": "2.4.4",
"description": "A viewer application for EPUB files.",
"repository": "https://github.com/d-i-t-a/R2D2BC",
"license": "Apache-2.0",
Expand Down
30 changes: 16 additions & 14 deletions src/model/user-settings/UserSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ export class UserSettings implements IUserSettings {
log.log(settings.verticalScroll);
}
if (initialUserSettings.appearance) {
settings.appearance = UserSettings.parseAppearanceSetting(initialUserSettings.appearance)
settings.appearance = UserSettings.parseAppearanceSetting(
initialUserSettings.appearance
);
let prop = settings.userProperties.getByRef(ReadiumCSS.APPEARANCE_REF);
if (prop) {
prop.value = settings.appearance;
Expand Down Expand Up @@ -953,8 +955,9 @@ export class UserSettings implements IUserSettings {
}

async resetUserSettings(): Promise<void> {
await this.store.remove(this.USERSETTINGS);
this.store.remove(this.USERSETTINGS);
await this.reset();
this.viewChangeCallback();
this.settingsChangeCallback();
}

Expand Down Expand Up @@ -987,7 +990,9 @@ export class UserSettings implements IUserSettings {

async applyUserSettings(userSettings: Partial<UserSettings>): Promise<void> {
if (userSettings.appearance) {
this.appearance = UserSettings.parseAppearanceSetting(userSettings.appearance)
this.appearance = UserSettings.parseAppearanceSetting(
userSettings.appearance
);
let prop = this.userProperties?.getByRef(ReadiumCSS.APPEARANCE_REF);
if (prop) {
prop.value = this.appearance;
Expand Down Expand Up @@ -1119,10 +1124,7 @@ export class UserSettings implements IUserSettings {
inputSetting: InitialUserSettings["appearance"]
): number {
let a: string;
if (
inputSetting === "day" ||
inputSetting === "readium-default-on"
) {
if (inputSetting === "day" || inputSetting === "readium-default-on") {
a = UserSettings.appearanceValues[0];
} else if (
inputSetting === "sepia" ||
Expand All @@ -1137,9 +1139,7 @@ export class UserSettings implements IUserSettings {
} else {
a = inputSetting;
}
return UserSettings.appearanceValues.findIndex(
(el: any) => el === a
);
return UserSettings.appearanceValues.findIndex((el: any) => el === a);
}

async scroll(scroll: boolean): Promise<void> {
Expand All @@ -1163,8 +1163,9 @@ export class UserSettings implements IUserSettings {
(
this.userProperties?.getByRef(ReadiumCSS.FONT_SIZE_REF) as Incremental
).increment();
this.fontSize = this.userProperties?.getByRef(ReadiumCSS.FONT_SIZE_REF)
?.value;
this.fontSize = this.userProperties?.getByRef(
ReadiumCSS.FONT_SIZE_REF
)?.value;
let prop = this.userProperties?.getByRef(ReadiumCSS.FONT_SIZE_REF);
if (prop) {
await this.storeProperty(prop);
Expand Down Expand Up @@ -1216,8 +1217,9 @@ export class UserSettings implements IUserSettings {
(
this.userProperties?.getByRef(ReadiumCSS.FONT_SIZE_REF) as Incremental
).decrement();
this.fontSize = this.userProperties?.getByRef(ReadiumCSS.FONT_SIZE_REF)
?.value;
this.fontSize = this.userProperties?.getByRef(
ReadiumCSS.FONT_SIZE_REF
)?.value;
let prop = this.userProperties?.getByRef(ReadiumCSS.FONT_SIZE_REF);
if (prop) {
await this.storeProperty(prop);
Expand Down
23 changes: 21 additions & 2 deletions src/modules/protection/ContentProtectionModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1435,8 +1435,27 @@ export class ContentProtectionModule implements ReaderModule {
const windowRight = windowLeft + this.wrapper.clientWidth;
const right = rect.left + rect.width;
const bottom = rect.top + rect.height;
const windowTop = this.wrapper.scrollTop;
const windowBottom = windowTop + this.wrapper.clientHeight;
const windowTop =
this.wrapper.scrollTop -
(rect.node.parentElement
? parseInt(
getComputedStyle(rect.node.parentElement).lineHeight.replace(
"px",
""
)
)
: 10);
const windowBottom =
windowTop +
this.wrapper.clientHeight +
(rect.node.parentElement
? parseInt(
getComputedStyle(rect.node.parentElement).lineHeight.replace(
"px",
""
)
)
: 10);

const isAbove = bottom < windowTop;
const isBelow = rect.top > windowBottom;
Expand Down

0 comments on commit 1413711

Please sign in to comment.