Skip to content

Commit

Permalink
Merge pull request #5561 from dodona-edu/fix/indicator-broken
Browse files Browse the repository at this point in the history
Fix series indicator on course page
  • Loading branch information
jorg-vr authored May 31, 2024
2 parents b215875 + 7b3cd2f commit 5a69821
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/assets/javascripts/scrollspy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,12 @@ export class ScrollSpy {
getCurrentSection(): HTMLElement | null {
this.sections = document.querySelectorAll(this.options.sectionSelector);
for (let i = 0; i < this.sections.length; i++) {
/**
* @type {HTMLElement}
*/
const section = this.sections[i];
// get the parent of the parent of the anchor
const startAt = section.parentElement.parentElement.offsetTop;
const endAt = startAt + section.parentElement.parentElement.offsetHeight;
const section: HTMLElement = this.sections[i];
// this is a series card specific modification
// it gets the series card encapsulating the anchor tag
const seriesCard = section.closest<HTMLElement>(".series");
const startAt = seriesCard.offsetTop;
const endAt = startAt + seriesCard.offsetHeight;
const currentPosition =
(document.documentElement.scrollTop ||
document.body.scrollTop) + this.options.offset;
Expand Down

0 comments on commit 5a69821

Please sign in to comment.