mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
Merge branch 'master' of github.com:jonobr1/gui-dat
This commit is contained in:
commit
712f2b94e3
@ -7,6 +7,14 @@ GUI.BooleanController = function() {
|
|||||||
var input = document.createElement('input');
|
var input = document.createElement('input');
|
||||||
input.setAttribute('type', 'checkbox');
|
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) {
|
this.domElement.addEventListener('click', function(e) {
|
||||||
input.checked = !input.checked;
|
input.checked = !input.checked;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -58,33 +58,6 @@ GUI.Slider = function(numberController, min, max, step, initValue) {
|
|||||||
this.fg.style.width = pct+"%";
|
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);
|
document.addEventListener('mousemove', onDrag, false);
|
||||||
|
|
||||||
this.value = initValue;
|
this.value = initValue;
|
||||||
|
Loading…
Reference in New Issue
Block a user