diff --git a/pwiki/page.js b/pwiki/page.js index e27654c..7363be1 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -2093,21 +2093,22 @@ object.Constructor('pWikiPageElement', Page, { // XXX CACHE... __last_refresh_location: undefined, - refresh: async function(full=false){ - // drop cache if re-refreshing or when full refresh requested... - // XXX CACHE... - ;(full - || this.__last_refresh_location == this.location) - && this.cache - && (this.cache = null) - this.__last_refresh_location = this.location - var dom = this.dom - dom.innerHTML = await this.text - for(var filter of Object.values(this.domFilters)){ - filter - && filter.call(this, dom) } - this.trigger('onLoad') - return this }, + refresh: types.event.Event('refresh', + async function(full=false){ + // drop cache if re-refreshing or when full refresh requested... + // XXX CACHE... + ;(full + || this.__last_refresh_location == this.location) + && this.cache + && (this.cache = null) + this.__last_refresh_location = this.location + var dom = this.dom + dom.innerHTML = await this.text + for(var filter of Object.values(this.domFilters)){ + filter + && filter.call(this, dom) } + this.trigger('onLoad') + return this }), // handle dom as first argument... __init__: function(dom, ...args){ diff --git a/pwiki2.html b/pwiki2.html index e53d0d3..b9eb9a3 100755 --- a/pwiki2.html +++ b/pwiki2.html @@ -374,6 +374,7 @@ var logTime = async function(promise, msg=''){ REFRESH_DELAY = 20 var refresh = async function(){ + pwiki.__prev_path = pwiki.path startSpinner() setTimeout(function(){ logTime( @@ -381,6 +382,9 @@ var refresh = async function(){ pwiki.location) }, REFRESH_DELAY) } +history.scrollRestoration = 'manual' + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // start loading pWiki... require(['./browser'], function(browser){ @@ -425,6 +429,7 @@ require(['./browser'], function(browser){ pwiki .onBeforeNavigate(function(){ + this.__prev_path = this.path saveAll() }) .navigate(async function(){ // NOTE: we do not need to directly update location.hash here as @@ -471,11 +476,11 @@ require(['./browser'], function(browser){ .querySelector('#'+ this.hash) .scrollIntoView() // restore history position... - // XXX HACK this will work only on full page... - : (document.scrollingElement.scrollTop = this.__scroll ?? 0) - - // XXX MediumEditor... - //setupMediumEditor() + // NOTE: only on navigate to new page... + // XXX HACK this will work only on full page pWiki and + // not on a element/nested pWiki... + : (this.__prev_path != this.path + && (document.scrollingElement.scrollTop = this.__scroll ?? 0)) // handle refresh... // NOTE: we need to do this as hashchange is only triggered