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

View file

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