~sircmpwn/godocs.io

gddo: gddo-server: Ensure selected example is in view v1 APPLIED

Adnan Maolood: 1
 gddo-server: Ensure selected example is in view

 1 files changed, 3 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/godocs.io/patches/22534/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH gddo] gddo-server: Ensure selected example is in view Export this patch

With JavaScript enabled, clicking a link to an example opens that
example up. However, when the link is below the example, this can result
in the example being out of view (i.e. only the bottom portion is
visible). Fix by scrolling it into view.
---
Tested on Firefox.

 gddo-server/assets/site.js | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gddo-server/assets/site.js b/gddo-server/assets/site.js
index eeb51d8..e237760 100644
--- a/gddo-server/assets/site.js
+++ b/gddo-server/assets/site.js
@@ -242,7 +242,9 @@ function onhashchange() {
	// open selected example
	var hash = window.location.hash
	if (hash.startsWith("#example-")) {
		document.querySelector(hash).parentElement.setAttribute("open", "")
		var example = document.querySelector(hash)
		example.parentElement.setAttribute("open", "")
		example.scrollIntoView()
	}
}
window.addEventListener("hashchange", onhashchange)
-- 
2.31.1
Thanks!

To git@git.sr.ht:~sircmpwn/gddo
   16608f7..c5d1165  master -> master