Skip to content

Commit

Permalink
JI-6581 Fix scrollToView only on user actions, not onload
Browse files Browse the repository at this point in the history
  • Loading branch information
icc committed Dec 12, 2024
1 parent 02cabba commit 0ea5c05
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,15 @@ export default class InteractiveBook extends H5P.EventDispatcher {
}
});

this.on('scrollToTop', () => {
this.on('scrollToTop', event => {
if (H5P.isFullscreen === true) {
const container = this.pageContent.container;
container.scrollBy(0, -container.scrollHeight);
}
else {
this.statusBarHeader.wrapper.scrollIntoView(true);
if (event.data !== false) { // Note: undefined is treated as true here
this.statusBarHeader.wrapper.scrollIntoView(true);
}
}
});

Expand Down Expand Up @@ -528,7 +530,7 @@ export default class InteractiveBook extends H5P.EventDispatcher {
}

H5P.trigger(this, 'changeHash', event.data);
H5P.trigger(this, 'scrollToTop');
H5P.trigger(this, 'scrollToTop', event.data.focus);
});

/**
Expand Down Expand Up @@ -1003,7 +1005,8 @@ export default class InteractiveBook extends H5P.EventDispatcher {
this.trigger('newChapter', {
h5pbookid: this.contentId,
chapter: `h5p-interactive-book-chapter-${this.params.chapters[this.activeChapter].subContentId}`,
section: 0
section: 0,
focus: event.data
});
}

Expand Down

0 comments on commit 0ea5c05

Please sign in to comment.