notes and experimenting...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-11-22 02:26:28 +03:00
parent 77e9f0819e
commit d9ab1f3349
2 changed files with 11 additions and 14 deletions

View File

@ -378,22 +378,18 @@ require(['./browser'], function(browser){
// scroll... // scroll...
// NOTE: we restore scroll position only on history navigation... // NOTE: we restore scroll position only on history navigation...
var save_scroll = function(){ var save_scroll = async function(){
history.replaceState( history.replaceState({
{ path: pwiki.location,
path: pwiki.location, // XXX HACK this will work only on full page...
// XXX HACK this will work only on full page... scroll: document.scrollingElement.scrollTop,
scroll: document.scrollingElement.scrollTop, }, '', window.location.hash) }
},
'',
// XXX
window.location.hash) }
// save scroll position just after scroll is done... // save scroll position just after scroll is done...
var scrolling var _scrolling
window.addEventListener('scroll', function(evt){ window.addEventListener('scroll', function(evt){
scrolling _scrolling
&& clearTimeout(scrolling) && clearTimeout(_scrolling)
scrolling = setTimeout(save_scroll, 200) }) _scrolling = setTimeout(save_scroll, 200) })
// get scroll position from history state... // get scroll position from history state...
window.addEventListener('popstate', function(evt){ window.addEventListener('popstate', function(evt){
pwiki.__scroll = (evt.state ?? {}).scroll }) pwiki.__scroll = (evt.state ?? {}).scroll })

View File

@ -49,6 +49,7 @@
* await pwiki.parse('<macro src=../tags join=", ">@source(.)</macro>') * await pwiki.parse('<macro src=../tags join=", ">@source(.)</macro>')
* This will not: * This will not:
* await pwiki.parse('<macro src="../tags" join=", ">@source(.)</macro>') * await pwiki.parse('<macro src="../tags" join=", ">@source(.)</macro>')
* XXX might be a good idea to add a default template to draw a list...
* XXX FEATURE: make the pwiki "widget" work bot as an element and as a * XXX FEATURE: make the pwiki "widget" work bot as an element and as a
* full page (current)... * full page (current)...
* ...would need to handle stuff like history, url, nav locally... * ...would need to handle stuff like history, url, nav locally...