Skip to content

Instantly share code, notes, and snippets.

@ccnokes
Created February 1, 2017 04:08
Show Gist options
  • Save ccnokes/f88e70389652ab1a18354fd454ddf380 to your computer and use it in GitHub Desktop.
Save ccnokes/f88e70389652ab1a18354fd454ddf380 to your computer and use it in GitHub Desktop.
const $webview = document.querySelector('webview');
const $loader = document.querySelector('.loader');
let isInitialLoad = true;
$webview.addEventListener('did-start-loading', () => {
// we use client side rendering in the web app, so the loader is only needed on the first page load
if(isInitialLoad) {
$webview.classList.add('hide');
$loader.classList.remove('loader-hide');
isInitialLoad = false;
}
});
$webview.addEventListener('dom-ready', () => {
$webview.classList.remove('hide');
// have to delay in order for the webview show/resize to settle
setTimeout(() => {
$loader.classList.add('loader-hide');
}, 100);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment