diff --git a/controllers/controller.number.js b/controllers/controller.number.js index 37e35ad..3f8e3fb 100644 --- a/controllers/controller.number.js +++ b/controllers/controller.number.js @@ -62,6 +62,20 @@ var NumberController = function() { clickedNumberField = true; document.addEventListener('mousemove', dragNumberField, false); }, false); + + // Handle up arrow and down arrow + numberField.addEventListener('keydown', function(e) { + switch(e.keyCode) { + case 38: // up + var newVal = _this.getValue() + step; + _this.setValue(newVal); + break; + case 40: // down + var newVal = _this.getValue() - step; + _this.setValue(newVal); + break; + } + }, false); document.addEventListener('mouseup', function(e) { document.removeEventListener('mousemove', dragNumberField, false); diff --git a/demo/demo.css b/demo/demo.css index 9579001..966a9ad 100644 --- a/demo/demo.css +++ b/demo/demo.css @@ -48,40 +48,56 @@ h2 { margin-bottom: 24px; } -h2.collapsed { +h2.section { +margin: 0; +padding: 20px 0 20px; +cursor: pointer; +border-top: 1px dotted #ccc; +-webkit-transition: color 0.15s linear; +} +h2.section:hover { +color: #00aeff; +} - padding-top:24px; - border-top: 1px solid #ccc; - margin-top: 0; - } - -/* -h2.collapsed { +div.collapsed h2, div.expanded h2 { float: left; clear: both; width: 100%; -cursor: pointer; + cursor: pointer; } -h2.collapsed:before { -content: '+'; -font-weight: normal; -line-height: 2px; -float: left; -margin-top: 6px; -margin-right: 6px; -font-size: 9px; -font-family: Monaco, monospace; -} -h2.collapsed:hover:before { -color: red; +h2.last { +border-bottom: 1px dotted #ccc; +margin-bottom: 20px; } -.collapsable { -clear: both; +div.expanded h2:before { + content: '-'; +} +div.collapsed h2:before { + content: '+'; +} +div.expanded h2:before, div.collapsed h2:before { + font-weight: normal; + line-height: 2px; + float: left; + margin-top: 6px; + margin-right: 6px; + font-size: 9px; + font-family: Monaco, monospace; +} -display: none; -}*/ +div.collapsed .collapsable { + overflow: hidden; + clear: both; + height: 0; +} +div.expanded .collapsable { + overflow: hidden; + clear: both; + height: auto; +} +div.expanded { cursor: pointer; } #helvetica-demo { position: absolute; diff --git a/demo/demo.js b/demo/demo.js index 62eca6e..e002bd1 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -224,5 +224,4 @@ function FizzyText(message) { } - } diff --git a/gui.css b/gui.css index c06bbc3..a3cb075 100644 --- a/gui.css +++ b/gui.css @@ -1,8 +1,8 @@ #guidat { position: fixed; top: 0; -left: 0; -width: 100%; +right: 0; +width: auto; z-index: 1001; text-align: right; } diff --git a/gui.js b/gui.js index 9291dc3..5860a71 100644 --- a/gui.js +++ b/gui.js @@ -22,8 +22,6 @@ var GUI = function() { var _this = this; - - var open = false; var width = 280; @@ -338,7 +336,7 @@ var GUI = function() { } else { controllerContainer.style.overflowY = "hidden"; } - console.log(controllerHeight, openHeight); + // console.log(controllerHeight, openHeight); } var addHandlers = { @@ -399,7 +397,7 @@ var GUI = function() { // used in saveURL this.appearanceVars = function() { - return [open, width, openHeight]; + return [open, width, openHeight, controllerContainer.scrollTop] } var beginResize = function() { @@ -418,12 +416,26 @@ var GUI = function() { if (GUI.guiIndex < GUI.savedAppearanceVars.length) { + width = parseInt(GUI.savedAppearanceVars[GUI.guiIndex][1]); _this.domElement.style.width = width+"px"; openHeight = parseInt(GUI.savedAppearanceVars[GUI.guiIndex][2]); explicitOpenHeight = true; if (eval(GUI.savedAppearanceVars[GUI.guiIndex][0]) == true) { + curControllerContainerHeight = openHeight; + var t = GUI.savedAppearanceVars[GUI.guiIndex][3] + + // Hack. + setTimeout(function() { + controllerContainer.scrollTop = t; + }, 0); + + if (GUI.scrollTop > -1) { + console.log("hey"); + document.body.scrollTop = GUI.scrollTop; + } + resizeTo = openHeight; this.show(); } @@ -447,19 +459,24 @@ GUI.saveURL = function() { window.location = url; }; +GUI.scrollTop = -1; + // TODO: Not working in FF. GUI.load = function(saveString) { - GUI.savedAppearanceVars = []; - var vals = saveString.split(','); + + console.log(saveString); + + //GUI.savedAppearanceVars = []; + var vals = saveString.split(","); + console.log(vals); var numGuis = parseInt(vals[0]); - var vv = vals.splice(1, vals.length-1); - var numGuis = vals[0]; - console.log(numGuis); + GUI.scrollTop = parseInt(vals[1]); for (var i = 0; i < numGuis; i++) { - var appr = vv.splice(0, 3); + var appr = vals.splice(2, 4); GUI.savedAppearanceVars.push(appr); } - GUI.savedValues = vv; + + GUI.savedValues = vals.splice(2, vals.length); }; GUI.savedValues = []; @@ -470,10 +487,12 @@ GUI.getSaveString = function() { var vals = []; vals.push(GUI.allGuis.length); + vals.push(document.body.scrollTop); + for (var i in GUI.allGuis) { var av = GUI.allGuis[i].appearanceVars(); - for (var j = 0; j <= GUI.allGuis.length; j++) { + for (var j = 0; j < av.length; j++) { vals.push(av[j]); } } diff --git a/index.html b/index.html index a5c0527..1a2578b 100644 --- a/index.html +++ b/index.html @@ -30,7 +30,7 @@ @@ -74,8 +121,10 @@
+
+

GUI-DAT flag

@@ -133,34 +182,34 @@ window.onload = function() {
gui.add(obj, "propName").onChange(function(n) {
         alert("You changed me to " + n);
 });
--> - - -
-

The simplest way to save your parameters is via GUI.saveURL(). This method directs your browser to a URL containing the current GUI settings.

-
+	
+	
-
- -
-

Let's say you'd like to share your settings with someone. Instead of sending a long link with lots of parameters stored in it, you can make your saved settings the defaults.

+
+
+ - - -
-

Let's say you have a variable that changes by itself from time to time. If you'd like the GUI to reflect those changes, use the listen() method.

-
-gui.add(obj, "changingProperty").listen();
-
+ -
- -
-

By default, gui-dat will create an internal interval that checks for changes in the values you've marked with listen(). If you'd like to check for these changes in an interval of your own definition, use the following:

-
+	
-

Alternatively, you can forego calling listen() on individual controllers, and instead choose to monitor changes in all values controlled by your gui.

-
+	    	

Alternatively, you can forego calling listen() on individual controllers, and instead choose to monitor changes in all values controlled by your gui.

+
 gui.autoListen = false; // disables internal interval
 gui.add(obj, "add");
 gui.add(obj, "lotsa");
@@ -205,26 +253,24 @@ gui.add(obj, "properties");
 
 // Make your own loop
 setInterval(function() {
-        gui.listenAll(); // updates ALL values managed by this gui
-}, 1000 / 60);
-
-
+ gui.listenAll(); // updates ALL values managed by this gui +}, 1000 / 60); + + - - -
-

You can instantiate multiple GUI objects and name them however you'd like.

-
-var gui1 = new GUI();
+	
-

By default, gui-dat panels will be automatically added to the HTML document and fixed to the top of the screen. You can disable this behavior / styling and append the gui DOM element to a container of your choosing.

-
+	    	

By default, gui-dat panels will be automatically added to the HTML document and fixed to the top of the screen. You can disable this behavior / styling and append the gui DOM element to a container of your choosing.

+
 // Notice this belongs to the GUI class (uppercase) 
 // and not an instance thereof.
 GUI.autoPlace = false; 
@@ -236,21 +282,22 @@ gui.domElement.style.position = "absolute";
 gui.domElement.style.top = "20px";
 gui.domElement.style.left = "20px";
 
-document.getElementById("my-gui-container").appendChild( gui.domElement );
-
-
- - - -
-
    -
  1. gui-dat panels are resizeable. Drag the toggle button.
  2. - -
  3. Press H to make panels invisible. Then press H to show them again.
  4. -
- - +document.getElementById("my-gui-container").appendChild( gui.domElement ); +
- + + + +