mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
wtf? why did my GUI.js get overwritten...
This commit is contained in:
parent
a4a2e31334
commit
904157f062
@ -6,6 +6,10 @@ DAT.GUI = function(parameters) {
|
||||
parameters = {};
|
||||
}
|
||||
|
||||
if (parameters.height == undefined) {
|
||||
parameters.height = 300;
|
||||
}
|
||||
|
||||
var MIN_WIDTH = 240;
|
||||
var MAX_WIDTH = 500;
|
||||
|
||||
@ -19,11 +23,9 @@ DAT.GUI = function(parameters) {
|
||||
// Sum total of heights of controllers in this gui
|
||||
var controllerHeight;
|
||||
|
||||
var curControllerContainerHeight = 0;
|
||||
|
||||
var _this = this;
|
||||
|
||||
var open = false;
|
||||
var open = true;
|
||||
var width = 280;
|
||||
|
||||
// Prevents checkForOverflow bug in which loaded gui appearance
|
||||
@ -45,9 +47,10 @@ DAT.GUI = function(parameters) {
|
||||
this.domElement.setAttribute('class', 'guidat');
|
||||
this.domElement.style.width = width + 'px';
|
||||
|
||||
var curControllerContainerHeight = parameters.height;
|
||||
var controllerContainer = document.createElement('div');
|
||||
controllerContainer.setAttribute('class', 'guidat-controllers');
|
||||
controllerContainer.style.height = '0px';
|
||||
controllerContainer.style.height = curControllerContainerHeight + 'px';
|
||||
|
||||
// Firefox hack to prevent horizontal scrolling
|
||||
controllerContainer.addEventListener('DOMMouseScroll', function(e) {
|
||||
@ -71,11 +74,10 @@ DAT.GUI = function(parameters) {
|
||||
}, false);
|
||||
|
||||
|
||||
|
||||
var toggleButton = document.createElement('a');
|
||||
toggleButton.setAttribute('class', 'guidat-toggle');
|
||||
toggleButton.setAttribute('href', '#');
|
||||
toggleButton.innerHTML = openString;
|
||||
toggleButton.innerHTML = open ? closeString : openString;
|
||||
|
||||
var toggleDragged = false;
|
||||
var dragDisplacementY = 0;
|
||||
@ -273,14 +275,6 @@ DAT.GUI = function(parameters) {
|
||||
|
||||
this.add = function() {
|
||||
|
||||
if (arguments.length == 1) {
|
||||
var toReturn = [];
|
||||
for (var i in arguments[0]) {
|
||||
toReturn.push(_this.add(arguments[0], i));
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
var object = arguments[0];
|
||||
var propertyName = arguments[1];
|
||||
|
||||
@ -365,13 +359,10 @@ DAT.GUI = function(parameters) {
|
||||
'function': DAT.GUI.ControllerFunction
|
||||
};
|
||||
|
||||
|
||||
this.reset = function() {
|
||||
// TODO ... Set all values back to their initials.
|
||||
}
|
||||
|
||||
// DAT.GUI ... DAT.GUI
|
||||
|
||||
this.toggle = function() {
|
||||
open ? this.close() : this.open();
|
||||
};
|
||||
@ -381,6 +372,7 @@ DAT.GUI = function(parameters) {
|
||||
resizeTo = openHeight;
|
||||
clearTimeout(resizeTimeout);
|
||||
beginResize();
|
||||
adaptToScrollbar();
|
||||
open = true;
|
||||
}
|
||||
|
||||
@ -389,6 +381,7 @@ DAT.GUI = function(parameters) {
|
||||
resizeTo = 0;
|
||||
clearTimeout(resizeTimeout);
|
||||
beginResize();
|
||||
adaptToScrollbar();
|
||||
open = false;
|
||||
}
|
||||
|
||||
@ -404,13 +397,12 @@ DAT.GUI = function(parameters) {
|
||||
|
||||
var beginResize = function() {
|
||||
|
||||
curControllerContainerHeight = controllerContainer.offsetHeight;
|
||||
curControllerContainerHeight += (resizeTo - curControllerContainerHeight)
|
||||
* 0.6;
|
||||
|
||||
if (Math.abs(curControllerContainerHeight - resizeTo) < 1) {
|
||||
curControllerContainerHeight = resizeTo;
|
||||
adaptToScrollbar();
|
||||
|
||||
} else {
|
||||
resizeTimeout = setTimeout(beginResize, 1000 / 30);
|
||||
}
|
||||
@ -421,15 +413,14 @@ DAT.GUI = function(parameters) {
|
||||
}
|
||||
|
||||
var adaptToScrollbar = function() {
|
||||
// Clears lingering slider column
|
||||
_this.domElement.style.width = (width + 1) + 'px';
|
||||
// Clears lingering scrollbar column
|
||||
_this.domElement.style.width = (width - 1) + 'px';
|
||||
setTimeout(function() {
|
||||
_this.domElement.style.width = width + 'px';
|
||||
}, 1);
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Load saved appearance:
|
||||
|
||||
if (DAT.GUI.guiIndex < DAT.GUI.savedAppearanceVars.length) {
|
||||
@ -461,10 +452,12 @@ DAT.GUI = function(parameters) {
|
||||
DAT.GUI.allGuis.push(this);
|
||||
|
||||
// Add hide listener if this is the first DAT.GUI.
|
||||
|
||||
if (DAT.GUI.allGuis.length == 1) {
|
||||
|
||||
window.addEventListener('keyup', function(e) {
|
||||
// Hide on 'H'
|
||||
if (e.keyCode == 72) {
|
||||
if (!DAT.GUI.supressHotKeys && e.keyCode == 72) {
|
||||
DAT.GUI.toggleHide();
|
||||
}
|
||||
}, false);
|
||||
@ -490,6 +483,7 @@ DAT.GUI.autoPlaceContainer = null;
|
||||
DAT.GUI.allControllers = [];
|
||||
DAT.GUI.allGuis = [];
|
||||
|
||||
DAT.GUI.supressHotKeys = false;
|
||||
|
||||
DAT.GUI.toggleHide = function() {
|
||||
if (DAT.GUI.hidden) {
|
||||
@ -540,8 +534,7 @@ DAT.GUI.savedAppearanceVars = [];
|
||||
|
||||
DAT.GUI.getSaveString = function() {
|
||||
|
||||
var vals = [],
|
||||
i;
|
||||
var vals = [], i;
|
||||
|
||||
vals.push(DAT.GUI.allGuis.length);
|
||||
vals.push(document.body.scrollTop);
|
||||
@ -686,19 +679,19 @@ DAT.GUI.extendController = function(clazz) {
|
||||
DAT.GUI.addClass = function(domElement, className) {
|
||||
if (DAT.GUI.hasClass(domElement, className)) return;
|
||||
domElement.className += ' ' + className;
|
||||
};
|
||||
}
|
||||
|
||||
DAT.GUI.hasClass = function(domElement, className) {
|
||||
return domElement.className.indexOf(className) != -1;
|
||||
};
|
||||
}
|
||||
|
||||
DAT.GUI.removeClass = function(domElement, className) {
|
||||
var reg = new RegExp(' ' + className, 'g');
|
||||
domElement.className = domElement.className.replace(reg, '');
|
||||
};
|
||||
}
|
||||
|
||||
if (DAT.GUI.getVarFromURL('saveString') != null) {
|
||||
DAT.GUI.load(DAT.GUI.getVarFromURL('saveString'));
|
||||
}
|
||||
|
||||
window["DAT.GUI"] = DAT.GUI;
|
||||
window['DAT'] = DAT;
|
Loading…
Reference in New Issue
Block a user