diff --git a/package-lock.json b/package-lock.json index 5a4a6804..43d47fd0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@d-i-t-a/reader", - "version": "2.4.3", + "version": "2.4.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@d-i-t-a/reader", - "version": "2.4.3", + "version": "2.4.4", "license": "Apache-2.0", "dependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.21.11", diff --git a/package.json b/package.json index 780dab56..2228f758 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/model/user-settings/UserSettings.ts b/src/model/user-settings/UserSettings.ts index ab786223..e59d2e16 100644 --- a/src/model/user-settings/UserSettings.ts +++ b/src/model/user-settings/UserSettings.ts @@ -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; @@ -953,8 +955,9 @@ export class UserSettings implements IUserSettings { } async resetUserSettings(): Promise { - await this.store.remove(this.USERSETTINGS); + this.store.remove(this.USERSETTINGS); await this.reset(); + this.viewChangeCallback(); this.settingsChangeCallback(); } @@ -987,7 +990,9 @@ export class UserSettings implements IUserSettings { async applyUserSettings(userSettings: Partial): Promise { 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; @@ -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" || @@ -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 { @@ -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); @@ -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); diff --git a/src/modules/protection/ContentProtectionModule.ts b/src/modules/protection/ContentProtectionModule.ts index e250c0d3..3e24c096 100644 --- a/src/modules/protection/ContentProtectionModule.ts +++ b/src/modules/protection/ContentProtectionModule.ts @@ -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;