allow editors parent nodes to handle mouse wheel when editor is fully scrolled

This commit is contained in:
nightwing 2011-08-17 00:21:32 +05:00
commit eaa38022e5
2 changed files with 11 additions and 2 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() {
@ -304,7 +304,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();