Hide/show controls

This commit is contained in:
George Michael Brower 2011-01-23 16:56:22 -07:00
parent d140f6e02d
commit ba1ff6f492
2 changed files with 12 additions and 3 deletions

View File

@ -6,6 +6,9 @@ z-index: 200;
top: 0; top: 0;
left: 100%; left: 100%;
margin-left: -320px; margin-left: -320px;
-moz-transition: margin-top .2s ease-out;
-webkit-transition: margin-top .2s ease-out;
transition: margin-top .2s ease-out;
} }
#guidat-controllers { #guidat-controllers {

12
gui.js
View File

@ -94,6 +94,9 @@ var GUI = new function() {
var started = false; var started = false;
var open = false; var open = false;
// TODO: obtain this dynamically?
var domElementMarginTop = 301;
this.start = function() { this.start = function() {
domElement = document.createElement('div'); domElement = document.createElement('div');
@ -114,6 +117,8 @@ var GUI = new function() {
domElement.appendChild(controllerContainer); domElement.appendChild(controllerContainer);
domElement.appendChild(toggleButton); domElement.appendChild(toggleButton);
domElement.style.marginTop = -domElementMarginTop+"px";
document.body.appendChild(domElement); document.body.appendChild(domElement);
started = true; started = true;
@ -123,13 +128,14 @@ var GUI = new function() {
this.toggle = function() { this.toggle = function() {
if (open) { if (open) {
domElement.style.marginTop = -domElementMarginTop+"px";
// Close the menu. toggleButton.innerHTML = "Show Controls";
open = false; open = false;
} else { } else {
// Open the menu. domElement.style.marginTop = 0+"px";
toggleButton.innerHTML = "Hide Controls";
open = true; open = true;
} }