mirror of
				https://github.com/Wonderfall/hugo-WonderMod.git
				synced 2025-10-30 19:35:26 +01:00 
			
		
		
		
	Improve scripts for menu-scroll
- also fixes menu-scroll-position not working in search page
This commit is contained in:
		| @@ -23,14 +23,10 @@ | |||||||
| {{- partial "extend_footer.html" . }} | {{- partial "extend_footer.html" . }} | ||||||
|  |  | ||||||
| <script> | <script> | ||||||
|     window.onload = function () { |     let menu = document.getElementById('menu') | ||||||
|         if (localStorage.getItem("menu-scroll-position")) { |     menu.scrollLeft = localStorage.getItem("menu-scroll-position"); | ||||||
|             document.getElementById('menu').scrollLeft = localStorage.getItem("menu-scroll-position"); |     menu.onscroll = function () { | ||||||
|         } |         localStorage.setItem("menu-scroll-position", menu.scrollLeft); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     function menu_on_scroll() { |  | ||||||
|         localStorage.setItem("menu-scroll-position", document.getElementById('menu').scrollLeft); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     document.querySelectorAll('a[href^="#"]').forEach(anchor => { |     document.querySelectorAll('a[href^="#"]').forEach(anchor => { | ||||||
|   | |||||||
| @@ -139,7 +139,7 @@ | |||||||
|             </span> |             </span> | ||||||
|         </div> |         </div> | ||||||
|         {{- $currentPage := . }} |         {{- $currentPage := . }} | ||||||
|         <ul id="menu" onscroll="menu_on_scroll()"> |         <ul id="menu"> | ||||||
|             {{- range .Site.Menus.main }} |             {{- range .Site.Menus.main }} | ||||||
|             {{- $menu_item_url := (cond (strings.HasSuffix .URL "/") .URL (printf "%s/" .URL) ) | absLangURL }} |             {{- $menu_item_url := (cond (strings.HasSuffix .URL "/") .URL (printf "%s/" .URL) ) | absLangURL }} | ||||||
|             {{- $page_url:= $currentPage.Permalink | absLangURL }} |             {{- $page_url:= $currentPage.Permalink | absLangURL }} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Aditya Telange
					Aditya Telange