Skip to content

Commit

Permalink
Merge pull request #430 from d-i-t-a/develop
Browse files Browse the repository at this point in the history
2.1.10
  • Loading branch information
aferditamuriqi authored Feb 4, 2023
2 parents a0e50c9 + 99d46f4 commit e124987
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 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.1.9",
"version": "2.1.10",
"description": "A viewer application for EPUB files.",
"repository": "https://github.com/d-i-t-a/R2D2BC",
"license": "Apache-2.0",
Expand Down
20 changes: 14 additions & 6 deletions src/modules/history/HistoryModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export class HistoryModule implements ReaderModule {

private historyForwardAnchorElement: HTMLAnchorElement;
private historyBackAnchorElement: HTMLAnchorElement;
private historyCurrentIndex: number;
private history: Array<Locator> = [];
historyCurrentIndex: number;
history: Array<Locator> = [];

private constructor(
annotator: Annotator,
Expand Down Expand Up @@ -200,7 +200,13 @@ export class HistoryModule implements ReaderModule {
);
}

private async handleHistoryForwardClick(event: MouseEvent) {
async handleHistoryForwardClick(event: MouseEvent) {
await this.historyForward();
event.preventDefault();
event.stopPropagation();
}

async historyForward() {
if (this.history.length > 0) {
if (this.historyCurrentIndex + 1 < this.history.length) {
this.historyCurrentIndex = this.historyCurrentIndex + 1;
Expand All @@ -210,11 +216,15 @@ export class HistoryModule implements ReaderModule {
);
}
}
}

private async handleHistoryBackClick(event: MouseEvent) {
await this.historyBack();
event.preventDefault();
event.stopPropagation();
}

private async handleHistoryBackClick(event: MouseEvent) {
async historyBack() {
if (this.history.length > 0) {
if (this.historyCurrentIndex > 0) {
this.historyCurrentIndex = this.historyCurrentIndex - 1;
Expand All @@ -224,7 +234,5 @@ export class HistoryModule implements ReaderModule {
);
}
}
event.preventDefault();
event.stopPropagation();
}
}
17 changes: 17 additions & 0 deletions src/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,23 @@ export default class D2Reader {
return this.annotationModule?.getAnnotations();
}

/** History */
get history() {
return this.historyModule?.history;
}
/** Current index of history */
get historyCurrentIndex() {
return this.historyModule?.historyCurrentIndex;
}
/** History Back */
historyBack = async () => {
return this.historyModule?.historyBack();
};
/** History Forward */
historyForward = async () => {
return this.historyModule?.historyForward();
};

/**
* Search
*/
Expand Down

0 comments on commit e124987

Please sign in to comment.