Merge branch 'master' of github.com:jonobr1/gui-dat

This commit is contained in:
George Michael Brower 2011-04-05 15:23:18 -07:00
commit 712f2b94e3
2 changed files with 8 additions and 27 deletions

View File

@ -7,6 +7,14 @@ GUI.BooleanController = function() {
var input = document.createElement('input');
input.setAttribute('type', 'checkbox');
if(arguments[3]) {
input.checked = true;
this.setValue(true);
} else {
input.checked = false;
this.setValue(false);
}
this.domElement.addEventListener('click', function(e) {
input.checked = !input.checked;
e.preventDefault();

View File

@ -58,33 +58,6 @@ GUI.Slider = function(numberController, min, max, step, initValue) {
this.fg.style.width = pct+"%";
});
var onDrag = function(e) {
if (!clicked) return;
var pos = findPos(_this.domElement);
var val = GUI.map(e.pageX, pos[0], pos[0] + _this.domElement.offsetWidth, min, max);
val = Math.round(val/step)*step;
numberController.setValue(val);
};
this.domElement.addEventListener('mousedown', function(e) {
clicked = true;
x = px = e.pageX;
_this.domElement.setAttribute('class', 'guidat-slider-bg active');
_this.fg.setAttribute('class', 'guidat-slider-fg active');
onDrag(e);
document.addEventListener('mouseup', mouseup, false);
}, false);
var mouseup = function(e) {
_this.domElement.setAttribute('class', 'guidat-slider-bg');
_this.fg.setAttribute('class', 'guidat-slider-fg');
clicked = false;
if (numberController.finishChangeFunction != null) {
numberController.finishChangeFunction.call(this, numberController.getValue());
}
document.removeEventListener('mouseup', mouseup, false);
};
document.addEventListener('mousemove', onDrag, false);
this.value = initValue;