diff --git a/pwiki2.html b/pwiki2.html index fc5abe2..982de49 100755 --- a/pwiki2.html +++ b/pwiki2.html @@ -60,6 +60,9 @@ a:hover { margin-left: -50px; white-space: nowrap; + background: transparent; + pointer-events: none; + animation: fadein 2s 1; } .spinner span { @@ -70,6 +73,18 @@ a:hover { animation: loading 2s infinite ; animation-delay: calc(0.2s * var(--i)); } +body:not(.loading) .page.spinner { + display: none; +} +body.loading .page.spinner { + opacity: 0.9; + animation: fadein 1s 1; +} +body.loading .page.spinner span { + font-size: 1.5em; + animation: loading 3s infinite ; + animation-delay: calc(0.2s * var(--i)); +} @keyframes fadein { from { opacity: 0; @@ -169,7 +184,10 @@ require(['./browser'], function(browser){ path = /^\.\.?([\\\/].*)?$/.test(path) ? path : '/'+path - pwiki.location = [path, hash] }) + startSpinner() + // NOTE: setTimeout(..) to allow the spinner to start... + setTimeout(function(){ + pwiki.location = [path, hash] }, 0) }) pwiki .onBeforeNavigate(function(){ saveNow() }) @@ -192,6 +210,8 @@ require(['./browser'], function(browser){ && console.log(`## ${pwiki.path} (${Date.now() - t}ms)`) }) }) .onLoad(function(evt){ var that = this + // stop spinner... + stopSpinner() // handle title... document.querySelector('title').innerHTML = this.path // scroll to anchor element... @@ -208,11 +228,8 @@ require(['./browser'], function(browser){ // wait for stuff to finish... browser.setup.then(function(){ - // show current page... - pwiki.location = decodeURI(location.hash).slice(1) - - }) }) + pwiki.location = decodeURI(location.hash).slice(1) }) }) // XXX make this a 2 stage save -- first cache and then save to store... @@ -234,6 +251,12 @@ var saveNow = pwiki.get(path).raw = text }) } setInterval(saveNow, 5000) +// loading spinner... +window.startSpinner = function(){ + document.body.classList.add('loading') } +window.stopSpinner = function(){ + document.body.classList.remove('loading') } + // XXX var exportData = async function(){ @@ -267,6 +290,19 @@ var exportData = async function(){ +