tweaking and minor tweaks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-11-29 20:49:38 +03:00
parent 811ed21223
commit 901683bcca
2 changed files with 26 additions and 20 deletions

View File

@ -2093,7 +2093,8 @@ object.Constructor('pWikiPageElement', Page, {
// XXX CACHE... // XXX CACHE...
__last_refresh_location: undefined, __last_refresh_location: undefined,
refresh: async function(full=false){ refresh: types.event.Event('refresh',
async function(full=false){
// drop cache if re-refreshing or when full refresh requested... // drop cache if re-refreshing or when full refresh requested...
// XXX CACHE... // XXX CACHE...
;(full ;(full
@ -2107,7 +2108,7 @@ object.Constructor('pWikiPageElement', Page, {
filter filter
&& filter.call(this, dom) } && filter.call(this, dom) }
this.trigger('onLoad') this.trigger('onLoad')
return this }, return this }),
// handle dom as first argument... // handle dom as first argument...
__init__: function(dom, ...args){ __init__: function(dom, ...args){

View File

@ -374,6 +374,7 @@ var logTime = async function(promise, msg=''){
REFRESH_DELAY = 20 REFRESH_DELAY = 20
var refresh = async function(){ var refresh = async function(){
pwiki.__prev_path = pwiki.path
startSpinner() startSpinner()
setTimeout(function(){ setTimeout(function(){
logTime( logTime(
@ -381,6 +382,9 @@ var refresh = async function(){
pwiki.location) }, REFRESH_DELAY) } pwiki.location) }, REFRESH_DELAY) }
history.scrollRestoration = 'manual'
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// start loading pWiki... // start loading pWiki...
require(['./browser'], function(browser){ require(['./browser'], function(browser){
@ -425,6 +429,7 @@ require(['./browser'], function(browser){
pwiki pwiki
.onBeforeNavigate(function(){ .onBeforeNavigate(function(){
this.__prev_path = this.path
saveAll() }) saveAll() })
.navigate(async function(){ .navigate(async function(){
// NOTE: we do not need to directly update location.hash here as // NOTE: we do not need to directly update location.hash here as
@ -471,11 +476,11 @@ require(['./browser'], function(browser){
.querySelector('#'+ this.hash) .querySelector('#'+ this.hash)
.scrollIntoView() .scrollIntoView()
// restore history position... // restore history position...
// XXX HACK this will work only on full page... // NOTE: only on navigate to new page...
: (document.scrollingElement.scrollTop = this.__scroll ?? 0) // XXX HACK this will work only on full page pWiki and
// not on a element/nested pWiki...
// XXX MediumEditor... : (this.__prev_path != this.path
//setupMediumEditor() && (document.scrollingElement.scrollTop = this.__scroll ?? 0))
// handle refresh... // handle refresh...
// NOTE: we need to do this as hashchange is only triggered // NOTE: we need to do this as hashchange is only triggered