@@ -173,6 +173,8 @@ Layout.render
173173 a.appendChild(title);
174174 a.appendChild(comment);
175175
176+ a.addEventListener("click", () => scrollTo(a.href));
177+
176178 list_item.appendChild(a);
177179
178180 search_results.appendChild(list_item);
@@ -242,13 +244,7 @@ Layout.render
242244 console.log("going to", url);
243245 window.location = url;
244246
245- if (url.indexOf("#") != -1) {
246- let id = url.split("#")[1]
247- let el = document.getElementById(id);
248- console.log("id el", id, el);
249- if (el) setTimeout(() => {
250- console.log("scroll"); el.scrollIntoView();}, 10);
251- }
247+ scrollTo(url);
252248
253249 document.getElementById("in-package-search-input").value = "";
254250 results = [];
@@ -266,6 +262,16 @@ Layout.render
266262 }
267263 }
268264
265+ function scrollTo(url) {
266+ if (url.indexOf("#") != -1) {
267+ let id = url.split("#")[1]
268+ let el = document.getElementById(id);
269+ console.log("id el", id, el);
270+ if (el) setTimeout(() => {
271+ console.log("scroll"); el.scrollIntoView();}, 10);
272+ }
273+ }
274+
269275 document.getElementById("in-package-search-input").addEventListener("keydown", keydown);
270276 }
271277</script>
0 commit comments