diff --git a/lib/ace/mouse_handler.js b/lib/ace/mouse_handler.js index cf5ccb9a..aa706493 100644 --- a/lib/ace/mouse_handler.js +++ b/lib/ace/mouse_handler.js @@ -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); }; diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index ac5b3903..126f7744 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -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(); diff --git a/lib/ace/worker/worker_client.js b/lib/ace/worker/worker_client.js index 525e8add..f024b274 100644 --- a/lib/ace/worker/worker_client.js +++ b/lib/ace/worker/worker_client.js @@ -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; };