mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
updating pull request inline of szimek's request to delete duplicate methods in slider.js - great find
This commit is contained in:
parent
d249ca6bb3
commit
f95262fcd2
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user