Skip to content

Commit

Permalink
Updated TOC in Default2022 presentation style to be resizable
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchiecarroll committed Jun 17, 2023
1 parent 2ea7eae commit fd33e54
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,22 @@
</ul>
</nav>

<div class="columns pl-5 pr-5 fixedContent">
<div id="ContentContainer" class="columns pl-5 pr-5 fixedContent">
<div id="ShowHideTOCColumn" class="column is-hidden-tablet">
<a id="ShowHideTOC"><include item="showHideTOC" /></a>
</div>

<div id="TOCColumn" class="column is-hidden-mobile">
<div id="TOCColumn" class="column is-hidden-mobile" style="flex-basis: initial; flex-grow: 0.25">
<nav class="toc">
<ul id="TableOfContents" class="toc-menu">
<!-- TOC entries will be added client-side from the TOC fragment file -->
</ul>
</nav>
</div>

<div id="TopicContent" class="column content is-7">
<div id="Resizer" style="cursor: ew-resize; width: 5px; background: #e6e6e6; margin-top: 8px; margin-bottom: 12px"></div>

<div id="TopicContent" class="column content is-7" style="flex-grow: 1">
<!-- Topic content will go here -->
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,41 @@

// Ignore Spelling: fti json

//===============================================================================================================
// This section contains the methods used to handle resizing the TOC section

var resizer, tocDiv;

window.onload = function() {
resizer = document.getElementById("Resizer");
tocDiv = document.getElementById("TOCColumn");

resizer.addEventListener("mousedown", function(e) {
e.preventDefault();
document.addEventListener("mousemove", ResizerMouseMove);
document.addEventListener("mouseup", ResizerMouseUp);
});
}

function ResizerMouseMove(e) {
const container = document.getElementById("ContentContainer");
const containerRect = container.getBoundingClientRect();
const newWidth = e.clientX - containerRect.left - 80;

// Ensure that divs are not smaller than some arbitrary minimal width
const minWidth = 50; // pixels
const contentDivWidth = containerRect.width - newWidth;

if (newWidth > minWidth && contentDivWidth > minWidth) {
tocDiv.style.width = newWidth + 'px';
}
}

function ResizerMouseUp() {
document.removeEventListener("mousemove", ResizerMouseMove);
document.removeEventListener("mouseup", ResizerMouseUp);
}

//===============================================================================================================
// This section contains the methods used to implement the language filter

Expand Down

0 comments on commit fd33e54

Please sign in to comment.