raito icon indicating copy to clipboard operation
raito copied to clipboard

[bug?] invalid not so kind offset for reference links

Open mckaygerhard opened this issue 1 year ago • 5 comments

The current anchor reference implementation at #42 forced to have a hardcoded CSS trick see the video how on any reference the title is "cuttring off" by the scroll

offseterror

i was thinking in made a workaroun around scrollIntoView using scrollTo that permits to specify an offset, using a config variable if user wants.. with a default value set, i can made a pull request for if you wants..

index 4deecda..d607c3d 100644
--- a/index.html
+++ b/index.html
@@ -11,8 +11,9 @@
 <!-- USER CONFIG -->
 <script>
        const config = {
                sitePath: "/",
                browserRouter: false,
+               scrollworkaround: true,
                name: "Raito",
                components: ["docs/navbar", "docs/github"],
                errorMessage: "Page not found",
@@ -415,9 +412,17 @@
                                                loadContent();
                                        };
                        });
-               if (selector) document.getElementById(selector).scrollIntoView()
-
+               if (selector) {
+                       offsettag = window.innerHeight / 8
+                       taganchor = document.getElementById(selector);
+                       taganchor.scrollIntoView({behavior: "smooth", block: "start", inline: "start", offset: offsettag})
+                       if(config.scrollworkaround) {
+                               const y = taganchor.offsetTop - (offsettag);
+                               window.scrollTo( { top: y, left: 0, behavior: 'smooth' } );
+                       };
+               };
                document.body.classList.add("loaded");
+               
                if (!config.browserRouter) window.location.replace(config.sitePath + path);
        };
      

mckaygerhard avatar Nov 19 '23 15:11 mckaygerhard