Skip to content

Commit

Permalink
render locally to check
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed May 19, 2024
1 parent 5034c77 commit 8601574
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 90 deletions.
4 changes: 2 additions & 2 deletions .quarto/_freeze/README/execute-results/html.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions .quarto/_freeze/README/libs/bootstrap/bootstrap.min.css

Large diffs are not rendered by default.

31 changes: 14 additions & 17 deletions .quarto/_freeze/README/libs/quarto-html/quarto.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const layoutMarginEls = () => {
// Find any conflicting margin elements and add margins to the
// top to prevent overlap
const marginChildren = window.document.querySelectorAll(
".column-margin.column-container > * "
".column-margin.column-container > *, .margin-caption, .aside"
);

let lastBottom = 0;
Expand All @@ -18,25 +18,14 @@ const layoutMarginEls = () => {
// clear the top margin so we recompute it
marginChild.style.marginTop = null;
const top = marginChild.getBoundingClientRect().top + window.scrollY;
console.log({
childtop: marginChild.getBoundingClientRect().top,
scroll: window.scrollY,
top,
lastBottom,
});
if (top < lastBottom) {
const margin = lastBottom - top;
const marginChildStyle = window.getComputedStyle(marginChild);
const marginBottom = parseFloat(marginChildStyle["marginBottom"]);
const margin = lastBottom - top + marginBottom;
marginChild.style.marginTop = `${margin}px`;
}
const styles = window.getComputedStyle(marginChild);
const marginTop = parseFloat(styles["marginTop"]);

console.log({
top,
height: marginChild.getBoundingClientRect().height,
marginTop,
total: top + marginChild.getBoundingClientRect().height + marginTop,
});
lastBottom = top + marginChild.getBoundingClientRect().height + marginTop;
}
}
Expand All @@ -46,7 +35,15 @@ window.document.addEventListener("DOMContentLoaded", function (_event) {
// Recompute the position of margin elements anytime the body size changes
if (window.ResizeObserver) {
const resizeObserver = new window.ResizeObserver(
throttle(layoutMarginEls, 50)
throttle(() => {
layoutMarginEls();
if (
window.document.body.getBoundingClientRect().width < 990 &&
isReaderMode()
) {
quartoToggleReader();
}
}, 50)
);
resizeObserver.observe(window.document.body);
}
Expand Down Expand Up @@ -97,7 +94,7 @@ window.document.addEventListener("DOMContentLoaded", function (_event) {
if (link.href.indexOf("#") !== -1) {
const anchor = link.href.split("#")[1];
const heading = window.document.querySelector(
`[data-anchor-id=${anchor}]`
`[data-anchor-id="${anchor}"]`
);
if (heading) {
// Add the class
Expand Down
Loading

0 comments on commit 8601574

Please sign in to comment.