Skip to content

Commit

Permalink
Merge pull request #1144 from internetarchive/webdev-5711-page-change…
Browse files Browse the repository at this point in the history
…d-event

Dispatch custom event from bookreader for ia-book-actions
  • Loading branch information
nsharma123 authored Feb 21, 2023
2 parents 6df6ec5 + 0deed54 commit dc43e6c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/BookReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,11 @@ BookReader.prototype.updateFirstIndex = function(
if (this.options.initialSearchTerm && !suppressFragmentChange) {
this.suppressFragmentChange = false;
}
this.trigger('pageChanged');

this.trigger(BookReader.eventNames.pageChanged);

// event to know if user is actively reading
this.trigger(BookReader.eventNames.userAction);
this._components.navbar.updateNavIndexThrottled(index);
};

Expand Down Expand Up @@ -1540,6 +1544,12 @@ BookReader.prototype.bindNavigationHandlers = function() {
},
};

// custom event for auto-loan-renew in ia-book-actions
// - to know if user is actively reading
this.$('nav.BRcontrols li button').on('click', () => {
this.trigger(BookReader.eventNames.userAction);
});

jIcons.filter('.fit').bind('fit', function() {
// XXXmang implement autofit zoom
});
Expand Down
2 changes: 2 additions & 0 deletions src/BookReader/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ export const EVENTS = {
/** Indicates that the fragment (a serialization of the reader
* state) has changed. */
fragmentChange: 'fragmentChange',
pageChanged: 'pageChanged',
PostInit: 'PostInit',
stop: 'stop',
resize: 'resize',
userAction: 'userAction', // event to know if user is actively reading
// nav events:
navToggled: 'navToggled',
// menu click events
Expand Down

0 comments on commit dc43e6c

Please sign in to comment.