emit scroll events

This commit is contained in:
Fabian Jakobs 2011-12-19 12:02:42 +01:00
commit 02f1447e2c
2 changed files with 10 additions and 5 deletions

View file

@ -61,6 +61,9 @@ var Editor = function(renderer, session) {
var container = renderer.getContainerElement();
this.container = container;
this.renderer = renderer;
renderer.on("scrollX", this._emit.bind(this, "scrollX"));
renderer.on("scrollY", this._emit.bind(this, "scrollY"));
this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
this.keyBinding = new KeyBinding(this);
@ -177,7 +180,7 @@ var Editor = function(renderer, session) {
this.renderer.scrollToRow(session.getScrollTopRow());
this.renderer.updateFull();
this._dispatchEvent("changeSession", {
this._emit("changeSession", {
session: session,
oldSession: oldSession
});
@ -261,13 +264,13 @@ var Editor = function(renderer, session) {
this.onFocus = function() {
this.renderer.showCursor();
this.renderer.visualizeFocus();
this._dispatchEvent("focus");
this._emit("focus");
};
this.onBlur = function() {
this.renderer.hideCursor();
this.renderer.visualizeBlur();
this._dispatchEvent("blur");
this._emit("blur");
};
this.onDocumentChange = function(e) {
@ -281,7 +284,7 @@ var Editor = function(renderer, session) {
lastRow = Infinity;
this.renderer.updateLines(range.start.row, lastRow);
this._dispatchEvent("change", e);
this._emit("change", e);
// update cursor because tab characters can influence the cursor position
this.onCursorChange();
@ -543,7 +546,7 @@ var Editor = function(renderer, session) {
this.$selectionStyle = style;
this.onSelectionChange();
this._dispatchEvent("changeSelectionStyle", {data: style});
this._emit("changeSelectionStyle", {data: style});
};
this.getSelectionStyle = function() {

View file

@ -697,6 +697,7 @@ var VirtualRenderer = function(container, theme) {
if (this.scrollTop !== scrollTop) {
this.$loop.schedule(this.CHANGE_SCROLL);
this.scrollTop = scrollTop;
this._emit("scrollY", scrollTop);
}
};
@ -705,6 +706,7 @@ var VirtualRenderer = function(container, theme) {
scrollLeft = 0;
this.scroller.scrollLeft = scrollLeft;
this._emit("scrollX", this.scroller.scrollLeft);
};
this.scrollBy = function(deltaX, deltaY) {