treat horizontal scrolling just like vertical scrolling
This commit is contained in:
parent
1018f51b5e
commit
421e19ed78
2 changed files with 17 additions and 8 deletions
|
|
@ -120,8 +120,7 @@ var Window = exports.Window = function(theme) {
|
||||||
var position = this.buffer.selection.getCursor();
|
var position = this.buffer.selection.getCursor();
|
||||||
var pos = this.buffer.documentToScreenPosition(position);
|
var pos = this.buffer.documentToScreenPosition(position);
|
||||||
var cursorLeft = Math.round(
|
var cursorLeft = Math.round(
|
||||||
this.padding
|
this.padding + pos.column * this.characterSize.width
|
||||||
+ pos.column * this.characterSize.width
|
|
||||||
);
|
);
|
||||||
var cursorTop = (pos.row - (onScreen ? this.layerConfig.firstRowScreen : 0))
|
var cursorTop = (pos.row - (onScreen ? this.layerConfig.firstRowScreen : 0))
|
||||||
* this.characterSize.height;
|
* this.characterSize.height;
|
||||||
|
|
|
||||||
|
|
@ -91,10 +91,16 @@ var WindowView = function(windowModel, container) {
|
||||||
this.$cursorLayer = new CursorLayer(windowModel, this.content);
|
this.$cursorLayer = new CursorLayer(windowModel, this.content);
|
||||||
this.$horizScroll = true;
|
this.$horizScroll = true;
|
||||||
|
|
||||||
|
this.scrollTop = 0;
|
||||||
|
this.scrollLeft = 0;
|
||||||
this.scrollBar = new ScrollBar(container);
|
this.scrollBar = new ScrollBar(container);
|
||||||
this.scrollBar.addEventListener("scroll", this.onScroll.bind(this));
|
this.scrollBar.addEventListener("scroll", this.onScroll.bind(this));
|
||||||
|
|
||||||
|
var _self = this;
|
||||||
|
event.addListener(this.scroller, "scroll", function() {
|
||||||
|
_self.scrollToX(_self.scroller.scrollLeft);
|
||||||
|
});
|
||||||
|
|
||||||
this.scrollTop = 0;
|
|
||||||
event.addListener(this.$gutter, "click", this.$onGutterClick.bind(this));
|
event.addListener(this.$gutter, "click", this.$onGutterClick.bind(this));
|
||||||
event.addListener(this.$gutter, "dblclick", this.$onGutterClick.bind(this));
|
event.addListener(this.$gutter, "dblclick", this.$onGutterClick.bind(this));
|
||||||
|
|
||||||
|
|
@ -548,7 +554,7 @@ var WindowView = function(windowModel, container) {
|
||||||
|
|
||||||
var pos = this.model.getCursorPixelPosition();
|
var pos = this.model.getCursorPixelPosition();
|
||||||
|
|
||||||
var left = pos.left + this.model.padding;
|
var left = pos.left;
|
||||||
var top = pos.top;
|
var top = pos.top;
|
||||||
|
|
||||||
if (this.scrollTop > top) {
|
if (this.scrollTop > top) {
|
||||||
|
|
@ -559,7 +565,7 @@ var WindowView = function(windowModel, container) {
|
||||||
this.scrollToY(top + this.lineHeight - this.model.size.scrollerHeight);
|
this.scrollToY(top + this.lineHeight - this.model.size.scrollerHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
var scrollLeft = this.scroller.scrollLeft;
|
var scrollLeft = this.scrollLeft;
|
||||||
|
|
||||||
if (scrollLeft > left) {
|
if (scrollLeft > left) {
|
||||||
this.scrollToX(left);
|
this.scrollToX(left);
|
||||||
|
|
@ -578,7 +584,7 @@ var WindowView = function(windowModel, container) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getScrollLeft = function() {
|
this.getScrollLeft = function() {
|
||||||
return this.scroller.scrollLeft;
|
return this.scrollLeft;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getScrollTopRow = function() {
|
this.getScrollTopRow = function() {
|
||||||
|
|
@ -620,18 +626,22 @@ var WindowView = function(windowModel, container) {
|
||||||
if (scrollLeft <= this.model.padding)
|
if (scrollLeft <= this.model.padding)
|
||||||
scrollLeft = 0;
|
scrollLeft = 0;
|
||||||
|
|
||||||
|
if (this.scrollLeft === scrollLeft)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.scrollLeft = scrollLeft;
|
||||||
this.scroller.scrollLeft = scrollLeft;
|
this.scroller.scrollLeft = scrollLeft;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.scrollBy = function(deltaX, deltaY) {
|
this.scrollBy = function(deltaX, deltaY) {
|
||||||
deltaY && this.scrollToY(this.scrollTop + deltaY);
|
deltaY && this.scrollToY(this.scrollTop + deltaY);
|
||||||
deltaX && this.scrollToX(this.scroller.scrollLeft + deltaX);
|
deltaX && this.scrollToX(this.scrollLeft + deltaX);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.screenToTextCoordinates = function(pageX, pageY) {
|
this.screenToTextCoordinates = function(pageX, pageY) {
|
||||||
var canvasPos = this.scroller.getBoundingClientRect();
|
var canvasPos = this.scroller.getBoundingClientRect();
|
||||||
|
|
||||||
var col = Math.round((pageX + this.scroller.scrollLeft - canvasPos.left - this.model.padding - dom.getPageScrollLeft())
|
var col = Math.round((pageX + this.scrollLeft - canvasPos.left - this.model.padding - dom.getPageScrollLeft())
|
||||||
/ this.characterWidth);
|
/ this.characterWidth);
|
||||||
var row = Math.floor((pageY + this.scrollTop - canvasPos.top - dom.getPageScrollTop())
|
var row = Math.floor((pageY + this.scrollTop - canvasPos.top - dom.getPageScrollTop())
|
||||||
/ this.lineHeight);
|
/ this.lineHeight);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue