simplify animateScroll a little
This commit is contained in:
parent
621c7c3dc8
commit
fb2be29d5e
2 changed files with 35 additions and 38 deletions
|
|
@ -979,11 +979,13 @@ var Editor = function(renderer, session) {
|
||||||
}
|
}
|
||||||
this.$blockScrolling--;
|
this.$blockScrolling--;
|
||||||
|
|
||||||
this.renderer.animateScrolling(function() {
|
var scrollTop = renderer.scrollTop;
|
||||||
|
|
||||||
renderer.scrollBy(0, rows * config.lineHeight);
|
renderer.scrollBy(0, rows * config.lineHeight);
|
||||||
if (select != null)
|
if (select != null)
|
||||||
renderer.scrollCursorIntoView(null, 0.5);
|
renderer.scrollCursorIntoView(null, 0.5);
|
||||||
}, this);
|
|
||||||
|
renderer.animateScrolling(scrollTop);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.selectPageDown = function() {
|
this.selectPageDown = function() {
|
||||||
|
|
@ -1141,17 +1143,17 @@ var Editor = function(renderer, session) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.navigateFileEnd = function() {
|
this.navigateFileEnd = function() {
|
||||||
this.renderer.animateScrolling(function() {
|
var scrollTop = this.renderer.scrollTop;
|
||||||
this.selection.moveCursorFileEnd();
|
this.selection.moveCursorFileEnd();
|
||||||
this.clearSelection();
|
this.clearSelection();
|
||||||
}, this);
|
this.renderer.animateScrolling(scrollTop);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.navigateFileStart = function() {
|
this.navigateFileStart = function() {
|
||||||
this.renderer.animateScrolling(function() {
|
var scrollTop = this.renderer.scrollTop;
|
||||||
this.selection.moveCursorFileStart();
|
this.selection.moveCursorFileStart();
|
||||||
this.clearSelection();
|
this.clearSelection();
|
||||||
}, this);
|
this.renderer.animateScrolling(scrollTop);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.navigateWordRight = function() {
|
this.navigateWordRight = function() {
|
||||||
|
|
@ -1261,9 +1263,9 @@ var Editor = function(renderer, session) {
|
||||||
this.selection.setSelectionRange(range);
|
this.selection.setSelectionRange(range);
|
||||||
this.$blockScrolling -= 1;
|
this.$blockScrolling -= 1;
|
||||||
|
|
||||||
this.renderer.animateScrolling(function() {
|
var scrollTop = this.renderer.scrollTop;
|
||||||
this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
|
this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
|
||||||
}, this);
|
this.renderer.animateScrolling(scrollTop);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -757,18 +757,13 @@ var VirtualRenderer = function(container, theme) {
|
||||||
if (center)
|
if (center)
|
||||||
offset -= this.$size.scrollerHeight / 2;
|
offset -= this.$size.scrollerHeight / 2;
|
||||||
|
|
||||||
if (animate !== false) {
|
var initialScroll = this.scrollTop;
|
||||||
this.animateScrolling(function() {
|
|
||||||
this.session.setScrollTop(offset);
|
this.session.setScrollTop(offset);
|
||||||
}, this, callback);
|
if (animate !== false)
|
||||||
} else {
|
this.animateScrolling(initialScroll, callback);
|
||||||
this.session.setScrollTop(offset);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.animateScrolling = function(scrollFunc, self, callback) {
|
this.animateScrolling = function(fromValue, callback) {
|
||||||
var fromValue = this.scrollTop;
|
|
||||||
scrollFunc.call(self);
|
|
||||||
var toValue = this.scrollTop;
|
var toValue = this.scrollTop;
|
||||||
if (this.$animatedScroll && Math.abs(fromValue - toValue) < 100000) {
|
if (this.$animatedScroll && Math.abs(fromValue - toValue) < 100000) {
|
||||||
var _self = this;
|
var _self = this;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue