fix animated scroll in multiselect mode

This commit is contained in:
nightwing 2013-05-14 19:18:59 +04:00
commit ebafdd419d
3 changed files with 11 additions and 5 deletions

View file

@ -1799,6 +1799,8 @@ var Editor = function(renderer, session) {
this.session.unfold({row: lineNumber - 1, column: column || 0}); this.session.unfold({row: lineNumber - 1, column: column || 0});
this.$blockScrolling += 1; this.$blockScrolling += 1;
// todo: find a way to automatically exit multiselect mode
this.exitMultiSelectMode && this.exitMultiSelectMode()
this.moveCursorTo(lineNumber - 1, column || 0); this.moveCursorTo(lineNumber - 1, column || 0);
this.$blockScrolling -= 1; this.$blockScrolling -= 1;

View file

@ -499,9 +499,13 @@ var Editor = require("./editor").Editor;
this.inVirtualSelectionMode = false; this.inVirtualSelectionMode = false;
selection._eventRegistry = reg; selection._eventRegistry = reg;
selection.mergeOverlappingRanges(); selection.mergeOverlappingRanges();
var anim = this.renderer.$scrollAnimation;
this.onCursorChange(); this.onCursorChange();
this.onSelectionChange(); this.onSelectionChange();
if (anim && anim.from == anim.to)
this.renderer.animateScrolling(anim.from);
return result; return result;
}; };

View file

@ -105,7 +105,7 @@ var VirtualRenderer = function(container, theme) {
this.scrollBar = new ScrollBar(this.container); this.scrollBar = new ScrollBar(this.container);
this.scrollBar.addEventListener("scroll", function(e) { this.scrollBar.addEventListener("scroll", function(e) {
if (!_self.$inScrollAnimation) if (!_self.$scrollAnimation)
_self.session.setScrollTop(e.data); _self.session.setScrollTop(e.data);
}); });
@ -1063,10 +1063,10 @@ var VirtualRenderer = function(container, theme) {
this.animateScrolling = function(fromValue, callback) { this.animateScrolling = function(fromValue, callback) {
var toValue = this.scrollTop; var toValue = this.scrollTop;
if (this.$animatedScroll && Math.abs(fromValue - toValue) < 100000) { if (this.$animatedScroll) {
var _self = this; var _self = this;
var steps = _self.$calcSteps(fromValue, toValue); var steps = _self.$calcSteps(fromValue, toValue);
this.$inScrollAnimation = true; this.$scrollAnimation = {from: fromValue, to: toValue};
clearInterval(this.$timer); clearInterval(this.$timer);
@ -1083,7 +1083,7 @@ var VirtualRenderer = function(container, theme) {
} else { } else {
// do this on separate step to not get spurious scroll event from scrollbar // do this on separate step to not get spurious scroll event from scrollbar
_self.$timer = clearInterval(_self.$timer); _self.$timer = clearInterval(_self.$timer);
_self.$inScrollAnimation = false; _self.$scrollAnimation = null;
callback && callback(); callback && callback();
} }
}, 10); }, 10);