Permalink
Browse files

Not appending overlay at start, re-focusing parent window on completion

  • Loading branch information...
1 parent 1080818 commit 58b93c9125659e796ee5209f1c12de4bd6cdb67f @AndrewRayCode committed Jul 17, 2016
Showing with 13 additions and 2 deletions.
  1. +12 −1 client.js
  2. +1 −1 package.json
View
@@ -1,6 +1,8 @@
const BUILDING_ACTION = 'building';
const BUILT_ACTION = 'built';
+let firstRun = false;
+
// Note the below template uses the website variable, which is injected by the
// loader source code (index.js)
@@ -76,7 +78,6 @@ overlay.innerHTML = `
</div>
`;
-document.body.appendChild( overlay );
// How does this work? The contents of this file are concatenated along with
// the contents of https://github.com/glenjamin/webpack-hot-middleware/blob/master/client.js
@@ -85,10 +86,20 @@ document.body.appendChild( overlay );
// proud.
module.exports.subscribeAll(function subAll( message ) {
if( message.action === BUILDING_ACTION ) {
+
+ if( !firstRun ) {
+ document.body.appendChild( overlay );
+ firstRun = true;
+ }
+
overlay.style.display = 'block';
overlay.querySelector('iframe').contentWindow.focus();
+
} else if( message.action === BUILT_ACTION ) {
+
+ window.focus();
overlay.style.display = 'none';
+
}
});
View
@@ -1,6 +1,6 @@
{
"name": "webpack-hot-2048-loader",
- "version": "0.0.1",
+ "version": "0.0.2",
"description": "A Webpack loader that shows you 2048 during hot reload rebuilding from webpack-hot-middleware",
"main": "index.js",
"scripts": {

0 comments on commit 58b93c9

Please sign in to comment.