Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
vincerubinetti committed Feb 3, 2021
1 parent a1a5da9 commit 6e535ad
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions build/plugins/accordion.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
(startCollapsed === "auto" && isSmallScreen())
)
collapseHeading(heading);
else expandHeading(heading);
else expandElement(heading);
}

// attach hash change listener to window
Expand Down Expand Up @@ -68,7 +68,7 @@
// collapse section if expanded, expand if collapsed
function toggleCollapse(heading) {
if (heading.dataset.collapsed === "false") collapseHeading(heading);
else expandHeading(heading);
else expandElement(heading);
}

// elements to exclude from collapse, such as table of contents panel,
Expand All @@ -83,7 +83,7 @@
}

// expand section
function expandHeading(heading) {
function expandElement(heading) {
heading.setAttribute("data-collapsed", "false");
const children = getChildren(heading);
for (const child of children) child.setAttribute("data-collapsed", "false");
Expand Down
10 changes: 7 additions & 3 deletions build/plugins/core.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,22 @@
return false;
}

// expand heading containing element if necessary
function expandHeading(element) {
// expand any collapsed parent containers of element if necessary
function expandElement(element) {
if (isCollapsed(element)) {
// accordion plugin
const heading = firstBefore(element, "h2");
if (heading) heading.click();
// details/summary HTML element
const summary = firstBefore(element, "summary");
if (summary) summary.click();
}
}

// scroll to and focus element
function goToElement(element, offset) {
// expand accordion section if collapsed
expandHeading(element);
expandElement(element);
const y =
getRectInView(element).top -
getRectInView(document.documentElement).top -
Expand Down
2 changes: 1 addition & 1 deletion build/plugins/tooltips.html
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
// scroll to and focus element
function goToElement(element, offset) {
// expand accordion section if collapsed
expandHeading(element);
expandElement(element);
const y =
getRectInView(element).top -
getRectInView(document.documentElement).top -
Expand Down

0 comments on commit 6e535ad

Please sign in to comment.