Browse Source

add console toggle

Gregg Tavares 7 years ago
parent
commit
b5cbff9d54
1 changed files with 17 additions and 0 deletions
  1. 17 0
      threejs/resources/threejs-lessons-helper.js

+ 17 - 0
threejs/resources/threejs-lessons-helper.js

@@ -133,6 +133,23 @@
     });
     });
     var numLinesRemaining = 100;
     var numLinesRemaining = 100;
     var added = false;
     var added = false;
+    const toggle = document.createElement('div');
+    let show = false;
+    Object.assign(toggle.style, {
+      position: 'absolute',
+      right: 0,
+      bottom: 0,
+      background: '#EEE',
+      'max-height': '2ex',
+    });
+    toggle.addEventListener('click', showHideConsole);
+
+    function showHideConsole() {
+      show = !show;
+      toggle.textContent = show ? '☒' : '☐';
+      parent.style.display = show ? '' : 'none';
+    }
+    showHideConsole();
 
 
     function addLine(type, str) {
     function addLine(type, str) {
       var div = document.createElement('div');
       var div = document.createElement('div');