fixed the firefox horizontal issue

This commit is contained in:
Jono Brandel 2011-01-31 19:06:34 -08:00
parent 4f1fa0411b
commit 4354f96be7
3 changed files with 34 additions and 9 deletions

View File

@ -36,7 +36,7 @@ Controller.prototype.listen = function() {
} }
Controller.prototype.unlisten = function() { Controller.prototype.unlisten = function() {
this.parent.unlistenTo(this); // <--- hasn't been implemented yet this.parent.unlistenTo(this); // <--- hasn't been tested yet
return this; return this;
} }

17
gui.css
View File

@ -1,10 +1,15 @@
#guidat { #guidat {
position: fixed; position: fixed;
top: 0; top: 0;
right: 0; right: 0;
width: auto; width: auto;
z-index: 1001; z-index: 1001;
text-align: right; text-align: right;
}
.guidat * {
padding: 0px;
margin: 0px;
} }
.guidat { .guidat {

24
gui.js
View File

@ -37,11 +37,31 @@ var GUI = function() {
this.domElement = document.createElement('div'); this.domElement = document.createElement('div');
this.domElement.setAttribute('class', 'guidat'); this.domElement.setAttribute('class', 'guidat');
this.domElement.style.width = width+'px' this.domElement.style.width = width+'px';
var controllerContainer = document.createElement('div'); var controllerContainer = document.createElement('div');
controllerContainer.setAttribute('class', 'guidat-controllers'); controllerContainer.setAttribute('class', 'guidat-controllers');
// Firefox hack for horizontal scrolling
controllerContainer.addEventListener('DOMMouseScroll', function(e) {
var scrollAmount = this.scrollTop;
if (e.wheelDelta) {
scrollAmount+=e.wheelDelta;
} else if (e.detail) {
scrollAmount+=e.detail;
}
if (e.preventDefault) {
e.preventDefault();
}
e.returnValue = false;
controllerContainer.scrollTop = scrollAmount;
}, false);
controllerContainer.style.height = '0px'; controllerContainer.style.height = '0px';
var toggleButton = document.createElement('a'); var toggleButton = document.createElement('a');
@ -117,7 +137,6 @@ var GUI = function() {
document.addEventListener('mouseup', function(e) { document.addEventListener('mouseup', function(e) {
if (togglePressed && !toggleDragged) { if (togglePressed && !toggleDragged) {
_this.toggle(); _this.toggle();
@ -183,6 +202,7 @@ var GUI = function() {
if(GUI.autoPlaceContainer == null) { if(GUI.autoPlaceContainer == null) {
GUI.autoPlaceContainer = document.createElement('div'); GUI.autoPlaceContainer = document.createElement('div');
GUI.autoPlaceContainer.setAttribute("id", "guidat"); GUI.autoPlaceContainer.setAttribute("id", "guidat");
document.body.appendChild(GUI.autoPlaceContainer); document.body.appendChild(GUI.autoPlaceContainer);
} }
GUI.autoPlaceContainer.appendChild(this.domElement); GUI.autoPlaceContainer.appendChild(this.domElement);