Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
docs: Customize view transition and other layout shift improvements (#43763)
Danilo Leal63eb3ea7e086
diff --git a/docs/theme/index.hbs b/docs/theme/index.hbsindex 1e89021218b..98f64d41c3e 100644--- a/docs/theme/index.hbs+++ b/docs/theme/index.hbs@@ -3,11 +3,13 @@<head><!-- Book generated using mdBook --><meta charset="UTF-8">- <meta name="view-transition" content="same-origin"><style>+ @view-transition {+ navigation: auto;+ }::view-transition-old(root),::view-transition-new(root) {- animation-duration: 0.15s;+ animation-duration: 0.05s;}</style><!-- Theme initialization - must run before any CSS loads to prevent flicker -->diff --git a/docs/theme/page-toc.js b/docs/theme/page-toc.jsindex 5d1525025b8..1ca6f621de9 100644--- a/docs/theme/page-toc.js+++ b/docs/theme/page-toc.js@@ -56,7 +56,7 @@ const updateFunction = () => {}};-window.addEventListener("load", () => {+document.addEventListener("DOMContentLoaded", () => {const pagetoc = getPagetoc();const headers = [...document.getElementsByClassName("header")];diff --git a/docs/theme/plugins.js b/docs/theme/plugins.jsindex 18dd8ef9b8e..af9665dae63 100644--- a/docs/theme/plugins.js+++ b/docs/theme/plugins.js@@ -24,7 +24,8 @@ function detectOS() {var os = detectOS();console.log("Operating System:", os);-(function updateKeybindings() {+// Defer keybinding processing to avoid blocking initial render+function updateKeybindings() {const os = detectOS();const isMac = os === "Mac" || os === "iOS";@@ -34,19 +35,17 @@ console.log("Operating System:", os);element.classList.add("keybinding");}- function walkDOM(node) {- if (node.nodeType === Node.ELEMENT_NODE) {- if (node.tagName.toLowerCase() === "kbd") {- processKeybinding(node);- } else {- Array.from(node.children).forEach(walkDOM);- }- }- }+ // Process all kbd elements at once (more efficient than walking entire DOM)+ const kbdElements = document.querySelectorAll("kbd");+ kbdElements.forEach(processKeybinding);+}- // Start the process from the body- walkDOM(document.body);-})();+// Use requestIdleCallback if available, otherwise requestAnimationFrame+if (typeof requestIdleCallback === "function") {+ requestIdleCallback(updateKeybindings);+} else {+ requestAnimationFrame(updateKeybindings);+}function darkModeToggle() {var html = document.documentElement;@@ -59,11 +58,6 @@ function darkModeToggle() {html.setAttribute("data-color-scheme", theme);html.className = theme;localStorage.setItem("mdbook-theme", theme);-- // Force a repaint to ensure the changes take effect in the client immediately- document.body.style.display = "none";- document.body.offsetHeight;- document.body.style.display = "";}themeToggleButton.addEventListener("click", function (event) {@@ -226,6 +220,7 @@ const copyMarkdown = () => {// Initialize functionality when DOM is loadeddocument.addEventListener("DOMContentLoaded", () => {+ darkModeToggle();copyMarkdown();});