Skip to content
Snippets Groups Projects
Verified Commit 7f4affff authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

fix(table-of-content): fix scroll down

parent 3702f1a7
No related branches found
No related tags found
No related merge requests found
......@@ -162,7 +162,7 @@ class TableOfContent extends CustomElement {
if (this[scrollableParentSymbol] === getWindow()) {
if (
["absolute", "relative", "fixed", "sticky"].indexOf(
this[scrollableParentSymbol].style.position,
this[scrollableParentSymbol]?.style?.position,
) === -1
) {
this.style.position = "relative";
......@@ -176,7 +176,7 @@ class TableOfContent extends CustomElement {
} else {
if (
["absolute", "relative", "fixed", "sticky"].indexOf(
this[scrollableParentSymbol].style.position,
this[scrollableParentSymbol]?.style?.position,
) === -1
) {
this[scrollableParentSymbol].style.position = "relative";
......@@ -229,6 +229,25 @@ class TableOfContent extends CustomElement {
}
}
/**
* @private
* @param element
* @returns {number|number|*|number}
*/
function getScrollHeight(element) {
if (element instanceof ShadowRoot) {
return element.host.scrollHeight;
}
if (element === getWindow()) {
return element.document.documentElement.scrollHeight;
}
return element.scrollHeight;
}
/**
* @private
* @return {void}
......@@ -339,7 +358,7 @@ function initNavigation() {
this[scrollableParentSymbol].scrollTo(
0,
this[scrollableParentSymbol].scrollHeight,
getScrollHeight(this[scrollableParentSymbol]),
);
});
footer.appendChild(scrollToBottom);
......@@ -428,7 +447,6 @@ function getHeadings() {
const headings = element.querySelectorAll("h1, h2, h3, h4, h5, h6");
let nodeList = Array.from(headings);
// remove all with attribute data-monster-table-of-content-omit
nodeList = nodeList.filter((node) => {
return !node.hasAttribute("data-monster-table-of-content-omit");
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment