simplify scroll animations
This commit is contained in:
parent
256b88fcd0
commit
c72357c201
2 changed files with 54 additions and 62 deletions
|
|
@ -964,22 +964,20 @@ var Editor = function(renderer, session) {
|
|||
var config = this.renderer.layerConfig;
|
||||
var rows = dir * Math.floor(config.height / config.lineHeight);
|
||||
|
||||
renderer.scrollBy(0, rows * config.lineHeight);
|
||||
|
||||
if (select == null)
|
||||
return;
|
||||
|
||||
this.$blockScrolling++;
|
||||
if (select) {
|
||||
if (select == true) {
|
||||
this.selection.$moveSelection(function(){
|
||||
this.moveCursorBy(rows, 0);
|
||||
});
|
||||
} else {
|
||||
} else if (select == false) {
|
||||
this.selection.moveCursorBy(rows, 0);
|
||||
this.selection.clearSelection();
|
||||
}
|
||||
|
||||
this.$blockScrolling--;
|
||||
|
||||
this.renderer.animateScrolling(function() {
|
||||
renderer.scrollBy(0, rows * config.lineHeight);
|
||||
}, this);
|
||||
};
|
||||
|
||||
this.selectPageDown = function() {
|
||||
|
|
@ -1081,18 +1079,6 @@ var Editor = function(renderer, session) {
|
|||
this.scrollToLine(lineNumber - 1, true, animate);
|
||||
};
|
||||
|
||||
this.$gotoLine = function(row, column, animate, center) {
|
||||
var _self = this;
|
||||
|
||||
//@todo hide cursor
|
||||
|
||||
this.scrollToLine(row, center, animate, function(){
|
||||
_self.$blockScrolling += 1;
|
||||
_self.moveCursorTo(row, column || 0);
|
||||
_self.$blockScrolling -= 1;
|
||||
});
|
||||
}
|
||||
|
||||
this.navigateTo = function(row, column) {
|
||||
this.clearSelection();
|
||||
this.moveCursorTo(row, column);
|
||||
|
|
@ -1147,20 +1133,19 @@ var Editor = function(renderer, session) {
|
|||
this.selection.moveCursorLineEnd();
|
||||
this.clearSelection();
|
||||
};
|
||||
|
||||
|
||||
this.navigateFileEnd = function() {
|
||||
//this.selection.moveCursorFileEnd();
|
||||
var doc = this.session.getDocument();
|
||||
var row = doc.getLength() - 1;
|
||||
|
||||
this.$gotoLine(row, doc.getLine(row).length);
|
||||
this.clearSelection();
|
||||
this.renderer.animateScrolling(function() {
|
||||
this.selection.moveCursorFileEnd();
|
||||
this.clearSelection();
|
||||
}, this);
|
||||
};
|
||||
|
||||
this.navigateFileStart = function() {
|
||||
//this.selection.moveCursorFileStart();
|
||||
this.$gotoLine(0, 0);
|
||||
this.clearSelection();
|
||||
this.renderer.animateScrolling(function() {
|
||||
this.selection.moveCursorFileStart();
|
||||
this.clearSelection();
|
||||
}, this);
|
||||
};
|
||||
|
||||
this.navigateWordRight = function() {
|
||||
|
|
@ -1265,24 +1250,14 @@ var Editor = function(renderer, session) {
|
|||
|
||||
var range = this.$search.find(this.session);
|
||||
if (range) {
|
||||
this.session.unfold(range);
|
||||
|
||||
this.$blockScrolling += 1;
|
||||
this.session.unfold(range);
|
||||
this.selection.setSelectionRange(range);
|
||||
this.$blockScrolling -= 1;
|
||||
|
||||
if (this.getAnimatedScroll()) {
|
||||
var cursor = this.getCursorPosition();
|
||||
if (!this.isRowFullyVisible(cursor.row))
|
||||
this.scrollToLine(cursor.row, true, animate);
|
||||
|
||||
//@todo scroll X
|
||||
//if (!this.isColumnFullyVisible(cursor.column))
|
||||
//this.scrollToRow(cursor.column);
|
||||
}
|
||||
else {
|
||||
this.renderer.animateScrolling(function() {
|
||||
this.renderer.scrollSelectionIntoView(range.start, range.end);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue