Merge pull request #384 from nightwing/pullreq

small fix for using ace in nested in scrollable element
This commit is contained in:
Fabian Jakobs 2011-08-17 06:01:12 -07:00
commit 4632d4ac5c
3 changed files with 12 additions and 3 deletions

View file

@ -67,7 +67,7 @@ var MouseHandler = function(editor) {
event.addMultiMouseDownListener(mouseTarget, 0, 2, 500, this.onMouseDoubleClick.bind(this));
event.addMultiMouseDownListener(mouseTarget, 0, 3, 600, this.onMouseTripleClick.bind(this));
event.addMultiMouseDownListener(mouseTarget, 0, 4, 600, this.onMouseQuadClick.bind(this));
event.addMouseWheelListener(mouseTarget, this.onMouseWheel.bind(this));
event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this));
};
(function() {
@ -308,7 +308,8 @@ var MouseHandler = function(editor) {
var speed = this.$scrollSpeed * 2;
this.editor.renderer.scrollBy(e.wheelX * speed, e.wheelY * speed);
return event.preventDefault(e);
if (this.editor.renderer.isScrollableBy(e.wheelX, e.wheelY))
return event.preventDefault(e);
};

View file

@ -712,6 +712,14 @@ var VirtualRenderer = function(container, theme) {
deltaX && this.scrollToX(this.scroller.scrollLeft + deltaX);
};
this.isScrollableBy = function(deltaX, deltaY) {
if (deltaY < 0 && this.scrollTop > 0)
return true;
if (deltaY > 0 && this.scrollTop + this.$size.scrollerHeight < this.layerConfig.maxHeight)
return true;
// todo: handle horizontal scrolling
};
this.screenToTextCoordinates = function(pageX, pageY) {
var canvasPos = this.scroller.getBoundingClientRect();

View file

@ -104,7 +104,7 @@ var WorkerClient = function(topLevelNamespaces, packagedJs, module, classname) {
this.$normalizePath = function(path) {
if (!path.match(/^\w+:/))
path = location.protocol + "//" + location.host + location.pathname.replace(/\/.*?$/, "") + "/" + path.replace(/^\//, "");
path = location.protocol + "//" + location.host + location.pathname.replace(/\/[^\/]*$/, "") + "/" + path.replace(/^\//, "");
return path;
};