mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-17 16:41:39 +00:00
added scroll position to nav history...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
7b78b5133a
commit
77e9f0819e
33
pwiki2.html
33
pwiki2.html
@ -375,6 +375,29 @@ require(['./browser'], function(browser){
|
|||||||
// NOTE: this seems not to work if the REFRESH_DELAY is too small...
|
// NOTE: this seems not to work if the REFRESH_DELAY is too small...
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
pwiki.location = [path, hash] }, REFRESH_DELAY) })
|
pwiki.location = [path, hash] }, REFRESH_DELAY) })
|
||||||
|
|
||||||
|
// scroll...
|
||||||
|
// NOTE: we restore scroll position only on history navigation...
|
||||||
|
var save_scroll = function(){
|
||||||
|
history.replaceState(
|
||||||
|
{
|
||||||
|
path: pwiki.location,
|
||||||
|
// XXX HACK this will work only on full page...
|
||||||
|
scroll: document.scrollingElement.scrollTop,
|
||||||
|
},
|
||||||
|
'',
|
||||||
|
// XXX
|
||||||
|
window.location.hash) }
|
||||||
|
// save scroll position just after scroll is done...
|
||||||
|
var scrolling
|
||||||
|
window.addEventListener('scroll', function(evt){
|
||||||
|
scrolling
|
||||||
|
&& clearTimeout(scrolling)
|
||||||
|
scrolling = setTimeout(save_scroll, 200) })
|
||||||
|
// get scroll position from history state...
|
||||||
|
window.addEventListener('popstate', function(evt){
|
||||||
|
pwiki.__scroll = (evt.state ?? {}).scroll })
|
||||||
|
|
||||||
pwiki
|
pwiki
|
||||||
.onBeforeNavigate(function(){
|
.onBeforeNavigate(function(){
|
||||||
saveAll() })
|
saveAll() })
|
||||||
@ -416,11 +439,15 @@ require(['./browser'], function(browser){
|
|||||||
`${titles.length > 1 ?
|
`${titles.length > 1 ?
|
||||||
titles.at(-1).innerText
|
titles.at(-1).innerText
|
||||||
: this.title} — pWiki`
|
: this.title} — pWiki`
|
||||||
// scroll to anchor element...
|
// scroll...
|
||||||
this.hash
|
this.hash ?
|
||||||
&& this.dom
|
// to anchor element...
|
||||||
|
this.dom
|
||||||
.querySelector('#'+ this.hash)
|
.querySelector('#'+ this.hash)
|
||||||
.scrollIntoView()
|
.scrollIntoView()
|
||||||
|
// restore history position...
|
||||||
|
// XXX HACK this will work only on full page...
|
||||||
|
: (document.scrollingElement.scrollTop = this.__scroll ?? 0)
|
||||||
|
|
||||||
// XXX MediumEditor...
|
// XXX MediumEditor...
|
||||||
//setupMediumEditor()
|
//setupMediumEditor()
|
||||||
|
|||||||
@ -36,8 +36,6 @@
|
|||||||
* -
|
* -
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* XXX load new page at .scrollTop = 0 if no anchors are given...
|
|
||||||
* ...and/or remember scroll position per page...
|
|
||||||
* XXX sort: define a generic sort path argument...
|
* XXX sort: define a generic sort path argument...
|
||||||
* ...this will unify all interfaces (macros/patterns/etc)
|
* ...this will unify all interfaces (macros/patterns/etc)
|
||||||
* XXX macros: else/default macro args essentially mean the same thing, should we
|
* XXX macros: else/default macro args essentially mean the same thing, should we
|
||||||
@ -51,6 +49,10 @@
|
|||||||
* 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 FEATURE: make the pwiki "widget" work bot as an element and as a
|
||||||
|
* full page (current)...
|
||||||
|
* ...would need to handle stuff like history, url, nav locally...
|
||||||
|
* see: pwiki2.html
|
||||||
* XXX ASAP test: can we store the file handler with permissions in a ServiceWorker??
|
* XXX ASAP test: can we store the file handler with permissions in a ServiceWorker??
|
||||||
* XXX macros: Q: do we need macros for printing errors and the like???
|
* XXX macros: Q: do we need macros for printing errors and the like???
|
||||||
* XXX the parser should handle all action return values, including:
|
* XXX the parser should handle all action return values, including:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user