Merge pull request #693 from ajaxorg/feature/animscroll
* Added animation for scrolling for find and gotoline
This commit is contained in:
commit
f1c609db1e
9 changed files with 340 additions and 33 deletions
|
|
@ -11872,6 +11872,14 @@ var Editor = function(renderer, session) {
|
|||
this.getHighlightSelectedWord = function() {
|
||||
return this.$highlightSelectedWord;
|
||||
};
|
||||
|
||||
this.setAnimatedScroll = function(shouldAnimate){
|
||||
this.renderer.setAnimatedScroll(shouldAnimate);
|
||||
}
|
||||
|
||||
this.getAnimatedScroll = function(){
|
||||
this.rendered.getAnimatedScroll();
|
||||
}
|
||||
|
||||
this.setShowInvisibles = function(showInvisibles) {
|
||||
if (this.getShowInvisibles() == showInvisibles)
|
||||
|
|
@ -12484,7 +12492,17 @@ var Editor = function(renderer, session) {
|
|||
var range = this.$search.find(this.session);
|
||||
if (range) {
|
||||
this.session.unfold(range);
|
||||
this.selection.setSelectionRange(range); // this scrolls selection into view
|
||||
this.$blockScrolling += 1;
|
||||
this.selection.setSelectionRange(range);
|
||||
this.$blockScrolling -= 1;
|
||||
|
||||
var cursor = this.getCursorPosition();
|
||||
if (!this.isRowFullyVisible(cursor.row))
|
||||
this.scrollToLine(cursor.row, true);
|
||||
|
||||
//@todo scroll X
|
||||
//if (!this.isRowFullyVisible(cursor.row))
|
||||
//this.scrollToLine(cursor.row, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -12504,7 +12522,8 @@ var Editor = function(renderer, session) {
|
|||
|
||||
|
||||
exports.Editor = Editor;
|
||||
});/* vim:ts=4:sts=4:sw=4:
|
||||
});
|
||||
/* vim:ts=4:sts=4:sw=4:
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
|
@ -14730,6 +14749,8 @@ var VirtualRenderer = function(container, theme) {
|
|||
// Indicates whether the horizontal scrollbar is visible
|
||||
this.$horizScroll = true;
|
||||
this.$horizScrollAlwaysVisible = true;
|
||||
|
||||
this.$animatedScroll = false;
|
||||
|
||||
this.scrollBar = new ScrollBar(container);
|
||||
this.scrollBar.addEventListener("scroll", function(e) {
|
||||
|
|
@ -14901,6 +14922,14 @@ var VirtualRenderer = function(container, theme) {
|
|||
var limit = Math.floor(availableWidth / this.characterWidth);
|
||||
return this.session.adjustWrapLimit(limit);
|
||||
};
|
||||
|
||||
this.setAnimatedScroll = function(shouldAnimate){
|
||||
this.$animatedScroll = shouldAnimate;
|
||||
}
|
||||
|
||||
this.getAnimatedscroll = function(){
|
||||
return this.$animatedScroll
|
||||
}
|
||||
|
||||
this.setShowInvisibles = function(showInvisibles) {
|
||||
if (this.$textLayer.setShowInvisibles(showInvisibles))
|
||||
|
|
@ -15332,13 +15361,46 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.session.setScrollTop(row * this.lineHeight);
|
||||
};
|
||||
|
||||
//@todo I would like to make this animation a setting. How?
|
||||
|
||||
var STEPS = 10;
|
||||
function calcSteps(fromValue, toValue){
|
||||
var i = 0,
|
||||
l = STEPS,
|
||||
steps = [],
|
||||
func = function(t, x_min, dx) {
|
||||
if ((t /= .5) < 1)
|
||||
return dx / 2 * Math.pow(t, 3) + x_min;
|
||||
return dx / 2 * (Math.pow(t - 2, 3) + 2) + x_min;
|
||||
};
|
||||
|
||||
for (i = 0; i < l; ++i)
|
||||
steps.push(func(i / STEPS, fromValue, toValue - fromValue));
|
||||
steps.push(toValue);
|
||||
|
||||
return steps;
|
||||
}
|
||||
|
||||
this.scrollToLine = function(line, center) {
|
||||
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
|
||||
var offset = pos.top;
|
||||
if (center)
|
||||
offset -= this.$size.scrollerHeight / 2;
|
||||
|
||||
this.session.setScrollTop(offset);
|
||||
|
||||
if (this.$animatedScroll && Math.abs(offset - this.scrollTop) < 10000) {
|
||||
var i = 0, _self = this,
|
||||
steps = calcSteps(this.scrollTop, offset);
|
||||
clearInterval(_self.$timer);
|
||||
this.$timer = setInterval(function(){
|
||||
_self.session.setScrollTop(steps[i]);
|
||||
|
||||
if (++i == STEPS + 1)
|
||||
clearInterval(_self.$timer);
|
||||
}, 10);
|
||||
}
|
||||
else {
|
||||
this.session.setScrollTop(offset);
|
||||
}
|
||||
};
|
||||
|
||||
this.scrollToY = function(scrollTop) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
Ace
|
||||
version 0.2.0
|
||||
commit cbd29bc541998e7c2bee817d048aead94760f557
|
||||
commit d6a1779f4b00794b0dc56917371e25492083e6d7
|
||||
|
||||
|
||||
-->
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -2986,6 +2986,14 @@ var Editor = function(renderer, session) {
|
|||
this.getHighlightSelectedWord = function() {
|
||||
return this.$highlightSelectedWord;
|
||||
};
|
||||
|
||||
this.setAnimatedScroll = function(shouldAnimate){
|
||||
this.renderer.setAnimatedScroll(shouldAnimate);
|
||||
}
|
||||
|
||||
this.getAnimatedScroll = function(){
|
||||
this.rendered.getAnimatedScroll();
|
||||
}
|
||||
|
||||
this.setShowInvisibles = function(showInvisibles) {
|
||||
if (this.getShowInvisibles() == showInvisibles)
|
||||
|
|
@ -3598,7 +3606,17 @@ var Editor = function(renderer, session) {
|
|||
var range = this.$search.find(this.session);
|
||||
if (range) {
|
||||
this.session.unfold(range);
|
||||
this.selection.setSelectionRange(range); // this scrolls selection into view
|
||||
this.$blockScrolling += 1;
|
||||
this.selection.setSelectionRange(range);
|
||||
this.$blockScrolling -= 1;
|
||||
|
||||
var cursor = this.getCursorPosition();
|
||||
if (!this.isRowFullyVisible(cursor.row))
|
||||
this.scrollToLine(cursor.row, true);
|
||||
|
||||
//@todo scroll X
|
||||
//if (!this.isRowFullyVisible(cursor.row))
|
||||
//this.scrollToLine(cursor.row, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -3618,7 +3636,8 @@ var Editor = function(renderer, session) {
|
|||
|
||||
|
||||
exports.Editor = Editor;
|
||||
});/* ***** BEGIN LICENSE BLOCK *****
|
||||
});
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
|
|
@ -11925,6 +11944,8 @@ var VirtualRenderer = function(container, theme) {
|
|||
// Indicates whether the horizontal scrollbar is visible
|
||||
this.$horizScroll = true;
|
||||
this.$horizScrollAlwaysVisible = true;
|
||||
|
||||
this.$animatedScroll = false;
|
||||
|
||||
this.scrollBar = new ScrollBar(container);
|
||||
this.scrollBar.addEventListener("scroll", function(e) {
|
||||
|
|
@ -12096,6 +12117,14 @@ var VirtualRenderer = function(container, theme) {
|
|||
var limit = Math.floor(availableWidth / this.characterWidth);
|
||||
return this.session.adjustWrapLimit(limit);
|
||||
};
|
||||
|
||||
this.setAnimatedScroll = function(shouldAnimate){
|
||||
this.$animatedScroll = shouldAnimate;
|
||||
}
|
||||
|
||||
this.getAnimatedscroll = function(){
|
||||
return this.$animatedScroll
|
||||
}
|
||||
|
||||
this.setShowInvisibles = function(showInvisibles) {
|
||||
if (this.$textLayer.setShowInvisibles(showInvisibles))
|
||||
|
|
@ -12527,13 +12556,46 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.session.setScrollTop(row * this.lineHeight);
|
||||
};
|
||||
|
||||
//@todo I would like to make this animation a setting. How?
|
||||
|
||||
var STEPS = 10;
|
||||
function calcSteps(fromValue, toValue){
|
||||
var i = 0,
|
||||
l = STEPS,
|
||||
steps = [],
|
||||
func = function(t, x_min, dx) {
|
||||
if ((t /= .5) < 1)
|
||||
return dx / 2 * Math.pow(t, 3) + x_min;
|
||||
return dx / 2 * (Math.pow(t - 2, 3) + 2) + x_min;
|
||||
};
|
||||
|
||||
for (i = 0; i < l; ++i)
|
||||
steps.push(func(i / STEPS, fromValue, toValue - fromValue));
|
||||
steps.push(toValue);
|
||||
|
||||
return steps;
|
||||
}
|
||||
|
||||
this.scrollToLine = function(line, center) {
|
||||
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
|
||||
var offset = pos.top;
|
||||
if (center)
|
||||
offset -= this.$size.scrollerHeight / 2;
|
||||
|
||||
this.session.setScrollTop(offset);
|
||||
|
||||
if (this.$animatedScroll && Math.abs(offset - this.scrollTop) < 10000) {
|
||||
var i = 0, _self = this,
|
||||
steps = calcSteps(this.scrollTop, offset);
|
||||
clearInterval(_self.$timer);
|
||||
this.$timer = setInterval(function(){
|
||||
_self.session.setScrollTop(steps[i]);
|
||||
|
||||
if (++i == STEPS + 1)
|
||||
clearInterval(_self.$timer);
|
||||
}, 10);
|
||||
}
|
||||
else {
|
||||
this.session.setScrollTop(offset);
|
||||
}
|
||||
};
|
||||
|
||||
this.scrollToY = function(scrollTop) {
|
||||
|
|
|
|||
|
|
@ -2986,6 +2986,14 @@ var Editor = function(renderer, session) {
|
|||
this.getHighlightSelectedWord = function() {
|
||||
return this.$highlightSelectedWord;
|
||||
};
|
||||
|
||||
this.setAnimatedScroll = function(shouldAnimate){
|
||||
this.renderer.setAnimatedScroll(shouldAnimate);
|
||||
}
|
||||
|
||||
this.getAnimatedScroll = function(){
|
||||
this.rendered.getAnimatedScroll();
|
||||
}
|
||||
|
||||
this.setShowInvisibles = function(showInvisibles) {
|
||||
if (this.getShowInvisibles() == showInvisibles)
|
||||
|
|
@ -3598,7 +3606,17 @@ var Editor = function(renderer, session) {
|
|||
var range = this.$search.find(this.session);
|
||||
if (range) {
|
||||
this.session.unfold(range);
|
||||
this.selection.setSelectionRange(range); // this scrolls selection into view
|
||||
this.$blockScrolling += 1;
|
||||
this.selection.setSelectionRange(range);
|
||||
this.$blockScrolling -= 1;
|
||||
|
||||
var cursor = this.getCursorPosition();
|
||||
if (!this.isRowFullyVisible(cursor.row))
|
||||
this.scrollToLine(cursor.row, true);
|
||||
|
||||
//@todo scroll X
|
||||
//if (!this.isRowFullyVisible(cursor.row))
|
||||
//this.scrollToLine(cursor.row, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -3618,7 +3636,8 @@ var Editor = function(renderer, session) {
|
|||
|
||||
|
||||
exports.Editor = Editor;
|
||||
});/* ***** BEGIN LICENSE BLOCK *****
|
||||
});
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
|
|
@ -11925,6 +11944,8 @@ var VirtualRenderer = function(container, theme) {
|
|||
// Indicates whether the horizontal scrollbar is visible
|
||||
this.$horizScroll = true;
|
||||
this.$horizScrollAlwaysVisible = true;
|
||||
|
||||
this.$animatedScroll = false;
|
||||
|
||||
this.scrollBar = new ScrollBar(container);
|
||||
this.scrollBar.addEventListener("scroll", function(e) {
|
||||
|
|
@ -12096,6 +12117,14 @@ var VirtualRenderer = function(container, theme) {
|
|||
var limit = Math.floor(availableWidth / this.characterWidth);
|
||||
return this.session.adjustWrapLimit(limit);
|
||||
};
|
||||
|
||||
this.setAnimatedScroll = function(shouldAnimate){
|
||||
this.$animatedScroll = shouldAnimate;
|
||||
}
|
||||
|
||||
this.getAnimatedscroll = function(){
|
||||
return this.$animatedScroll
|
||||
}
|
||||
|
||||
this.setShowInvisibles = function(showInvisibles) {
|
||||
if (this.$textLayer.setShowInvisibles(showInvisibles))
|
||||
|
|
@ -12527,13 +12556,46 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.session.setScrollTop(row * this.lineHeight);
|
||||
};
|
||||
|
||||
//@todo I would like to make this animation a setting. How?
|
||||
|
||||
var STEPS = 10;
|
||||
function calcSteps(fromValue, toValue){
|
||||
var i = 0,
|
||||
l = STEPS,
|
||||
steps = [],
|
||||
func = function(t, x_min, dx) {
|
||||
if ((t /= .5) < 1)
|
||||
return dx / 2 * Math.pow(t, 3) + x_min;
|
||||
return dx / 2 * (Math.pow(t - 2, 3) + 2) + x_min;
|
||||
};
|
||||
|
||||
for (i = 0; i < l; ++i)
|
||||
steps.push(func(i / STEPS, fromValue, toValue - fromValue));
|
||||
steps.push(toValue);
|
||||
|
||||
return steps;
|
||||
}
|
||||
|
||||
this.scrollToLine = function(line, center) {
|
||||
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
|
||||
var offset = pos.top;
|
||||
if (center)
|
||||
offset -= this.$size.scrollerHeight / 2;
|
||||
|
||||
this.session.setScrollTop(offset);
|
||||
|
||||
if (this.$animatedScroll && Math.abs(offset - this.scrollTop) < 10000) {
|
||||
var i = 0, _self = this,
|
||||
steps = calcSteps(this.scrollTop, offset);
|
||||
clearInterval(_self.$timer);
|
||||
this.$timer = setInterval(function(){
|
||||
_self.session.setScrollTop(steps[i]);
|
||||
|
||||
if (++i == STEPS + 1)
|
||||
clearInterval(_self.$timer);
|
||||
}, 10);
|
||||
}
|
||||
else {
|
||||
this.session.setScrollTop(offset);
|
||||
}
|
||||
};
|
||||
|
||||
this.scrollToY = function(scrollTop) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -3553,6 +3553,14 @@ var Editor = function(renderer, session) {
|
|||
this.getHighlightSelectedWord = function() {
|
||||
return this.$highlightSelectedWord;
|
||||
};
|
||||
|
||||
this.setAnimatedScroll = function(shouldAnimate){
|
||||
this.renderer.setAnimatedScroll(shouldAnimate);
|
||||
}
|
||||
|
||||
this.getAnimatedScroll = function(){
|
||||
this.rendered.getAnimatedScroll();
|
||||
}
|
||||
|
||||
this.setShowInvisibles = function(showInvisibles) {
|
||||
if (this.getShowInvisibles() == showInvisibles)
|
||||
|
|
@ -4165,7 +4173,17 @@ var Editor = function(renderer, session) {
|
|||
var range = this.$search.find(this.session);
|
||||
if (range) {
|
||||
this.session.unfold(range);
|
||||
this.selection.setSelectionRange(range); // this scrolls selection into view
|
||||
this.$blockScrolling += 1;
|
||||
this.selection.setSelectionRange(range);
|
||||
this.$blockScrolling -= 1;
|
||||
|
||||
var cursor = this.getCursorPosition();
|
||||
if (!this.isRowFullyVisible(cursor.row))
|
||||
this.scrollToLine(cursor.row, true);
|
||||
|
||||
//@todo scroll X
|
||||
//if (!this.isRowFullyVisible(cursor.row))
|
||||
//this.scrollToLine(cursor.row, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -4185,7 +4203,8 @@ var Editor = function(renderer, session) {
|
|||
|
||||
|
||||
exports.Editor = Editor;
|
||||
});/* ***** BEGIN LICENSE BLOCK *****
|
||||
});
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
|
|
@ -12431,6 +12450,8 @@ var VirtualRenderer = function(container, theme) {
|
|||
// Indicates whether the horizontal scrollbar is visible
|
||||
this.$horizScroll = true;
|
||||
this.$horizScrollAlwaysVisible = true;
|
||||
|
||||
this.$animatedScroll = false;
|
||||
|
||||
this.scrollBar = new ScrollBar(container);
|
||||
this.scrollBar.addEventListener("scroll", function(e) {
|
||||
|
|
@ -12602,6 +12623,14 @@ var VirtualRenderer = function(container, theme) {
|
|||
var limit = Math.floor(availableWidth / this.characterWidth);
|
||||
return this.session.adjustWrapLimit(limit);
|
||||
};
|
||||
|
||||
this.setAnimatedScroll = function(shouldAnimate){
|
||||
this.$animatedScroll = shouldAnimate;
|
||||
}
|
||||
|
||||
this.getAnimatedscroll = function(){
|
||||
return this.$animatedScroll
|
||||
}
|
||||
|
||||
this.setShowInvisibles = function(showInvisibles) {
|
||||
if (this.$textLayer.setShowInvisibles(showInvisibles))
|
||||
|
|
@ -13033,13 +13062,46 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.session.setScrollTop(row * this.lineHeight);
|
||||
};
|
||||
|
||||
//@todo I would like to make this animation a setting. How?
|
||||
|
||||
var STEPS = 10;
|
||||
function calcSteps(fromValue, toValue){
|
||||
var i = 0,
|
||||
l = STEPS,
|
||||
steps = [],
|
||||
func = function(t, x_min, dx) {
|
||||
if ((t /= .5) < 1)
|
||||
return dx / 2 * Math.pow(t, 3) + x_min;
|
||||
return dx / 2 * (Math.pow(t - 2, 3) + 2) + x_min;
|
||||
};
|
||||
|
||||
for (i = 0; i < l; ++i)
|
||||
steps.push(func(i / STEPS, fromValue, toValue - fromValue));
|
||||
steps.push(toValue);
|
||||
|
||||
return steps;
|
||||
}
|
||||
|
||||
this.scrollToLine = function(line, center) {
|
||||
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
|
||||
var offset = pos.top;
|
||||
if (center)
|
||||
offset -= this.$size.scrollerHeight / 2;
|
||||
|
||||
this.session.setScrollTop(offset);
|
||||
|
||||
if (this.$animatedScroll && Math.abs(offset - this.scrollTop) < 10000) {
|
||||
var i = 0, _self = this,
|
||||
steps = calcSteps(this.scrollTop, offset);
|
||||
clearInterval(_self.$timer);
|
||||
this.$timer = setInterval(function(){
|
||||
_self.session.setScrollTop(steps[i]);
|
||||
|
||||
if (++i == STEPS + 1)
|
||||
clearInterval(_self.$timer);
|
||||
}, 10);
|
||||
}
|
||||
else {
|
||||
this.session.setScrollTop(offset);
|
||||
}
|
||||
};
|
||||
|
||||
this.scrollToY = function(scrollTop) {
|
||||
|
|
|
|||
|
|
@ -601,6 +601,14 @@ var Editor = function(renderer, session) {
|
|||
this.getHighlightSelectedWord = function() {
|
||||
return this.$highlightSelectedWord;
|
||||
};
|
||||
|
||||
this.setAnimatedScroll = function(shouldAnimate){
|
||||
this.renderer.setAnimatedScroll(shouldAnimate);
|
||||
}
|
||||
|
||||
this.getAnimatedScroll = function(){
|
||||
this.rendered.getAnimatedScroll();
|
||||
}
|
||||
|
||||
this.setShowInvisibles = function(showInvisibles) {
|
||||
if (this.getShowInvisibles() == showInvisibles)
|
||||
|
|
@ -1213,7 +1221,17 @@ var Editor = function(renderer, session) {
|
|||
var range = this.$search.find(this.session);
|
||||
if (range) {
|
||||
this.session.unfold(range);
|
||||
this.selection.setSelectionRange(range); // this scrolls selection into view
|
||||
this.$blockScrolling += 1;
|
||||
this.selection.setSelectionRange(range);
|
||||
this.$blockScrolling -= 1;
|
||||
|
||||
var cursor = this.getCursorPosition();
|
||||
if (!this.isRowFullyVisible(cursor.row))
|
||||
this.scrollToLine(cursor.row, true);
|
||||
|
||||
//@todo scroll X
|
||||
//if (!this.isRowFullyVisible(cursor.row))
|
||||
//this.scrollToLine(cursor.row, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1233,4 +1251,4 @@ var Editor = function(renderer, session) {
|
|||
|
||||
|
||||
exports.Editor = Editor;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -60,13 +60,13 @@ dom.importCssString(editorCss, "ace_editor");
|
|||
|
||||
var VirtualRenderer = function(container, theme) {
|
||||
var _self = this;
|
||||
|
||||
|
||||
this.container = container;
|
||||
|
||||
// TODO: this breaks rendering in Cloud9 with multiple ace instances
|
||||
// // Imports CSS once per DOM document ('ace_editor' serves as an identifier).
|
||||
// dom.importCssString(editorCss, "ace_editor", container.ownerDocument);
|
||||
|
||||
|
||||
dom.addCssClass(container, "ace_editor");
|
||||
|
||||
this.setTheme(theme);
|
||||
|
|
@ -84,8 +84,8 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.scroller.appendChild(this.content);
|
||||
|
||||
this.$gutterLayer = new GutterLayer(this.$gutter);
|
||||
this.$gutterLayer.on("changeGutterWidth", this.onResize.bind(this, true));
|
||||
|
||||
this.$gutterLayer.on("changeGutterWidth", this.onResize.bind(this, true));
|
||||
|
||||
this.$markerBack = new MarkerLayer(this.content);
|
||||
|
||||
var textLayer = this.$textLayer = new TextLayer(this.content);
|
||||
|
|
@ -103,6 +103,8 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.$horizScroll = true;
|
||||
this.$horizScrollAlwaysVisible = true;
|
||||
|
||||
this.$animatedScroll = false;
|
||||
|
||||
this.scrollBar = new ScrollBar(container);
|
||||
this.scrollBar.addEventListener("scroll", function(e) {
|
||||
_self.session.setScrollTop(e.data);
|
||||
|
|
@ -110,7 +112,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
|
||||
this.scrollTop = 0;
|
||||
this.scrollLeft = 0;
|
||||
|
||||
|
||||
event.addListener(this.scroller, "scroll", function() {
|
||||
var scrollLeft = _self.scroller.scrollLeft;
|
||||
_self.scrollLeft = scrollLeft;
|
||||
|
|
@ -274,6 +276,14 @@ var VirtualRenderer = function(container, theme) {
|
|||
return this.session.adjustWrapLimit(limit);
|
||||
};
|
||||
|
||||
this.setAnimatedScroll = function(shouldAnimate){
|
||||
this.$animatedScroll = shouldAnimate;
|
||||
}
|
||||
|
||||
this.getAnimatedscroll = function(){
|
||||
return this.$animatedScroll
|
||||
}
|
||||
|
||||
this.setShowInvisibles = function(showInvisibles) {
|
||||
if (this.$textLayer.setShowInvisibles(showInvisibles))
|
||||
this.$loop.schedule(this.CHANGE_TEXT);
|
||||
|
|
@ -352,7 +362,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
// this persists in IE9
|
||||
if (useragent.isIE)
|
||||
return;
|
||||
|
||||
|
||||
if (this.layerConfig.lastRow === 0)
|
||||
return;
|
||||
|
||||
|
|
@ -428,13 +438,13 @@ var VirtualRenderer = function(container, theme) {
|
|||
// horizontal scrolling
|
||||
if (changes & this.CHANGE_H_SCROLL) {
|
||||
this.scroller.scrollLeft = this.scrollLeft;
|
||||
|
||||
|
||||
// read the value after writing it since the value might get clipped
|
||||
var scrollLeft = this.scroller.scrollLeft;
|
||||
this.scrollLeft = scrollLeft;
|
||||
this.session.setScrollLeft(scrollLeft);
|
||||
}
|
||||
|
||||
|
||||
// full
|
||||
if (changes & this.CHANGE_FULL) {
|
||||
this.$textLayer.checkForSizeChanges();
|
||||
|
|
@ -704,13 +714,44 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.session.setScrollTop(row * this.lineHeight);
|
||||
};
|
||||
|
||||
var STEPS = 10;
|
||||
function calcSteps(fromValue, toValue){
|
||||
var i = 0,
|
||||
l = STEPS,
|
||||
steps = [],
|
||||
func = function(t, x_min, dx) {
|
||||
if ((t /= .5) < 1)
|
||||
return dx / 2 * Math.pow(t, 3) + x_min;
|
||||
return dx / 2 * (Math.pow(t - 2, 3) + 2) + x_min;
|
||||
};
|
||||
|
||||
for (i = 0; i < l; ++i)
|
||||
steps.push(func(i / STEPS, fromValue, toValue - fromValue));
|
||||
steps.push(toValue);
|
||||
|
||||
return steps;
|
||||
}
|
||||
|
||||
this.scrollToLine = function(line, center) {
|
||||
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
|
||||
var offset = pos.top;
|
||||
if (center)
|
||||
offset -= this.$size.scrollerHeight / 2;
|
||||
|
||||
this.session.setScrollTop(offset);
|
||||
if (this.$animatedScroll && Math.abs(offset - this.scrollTop) < 10000) {
|
||||
var i = 0, _self = this,
|
||||
steps = calcSteps(this.scrollTop, offset);
|
||||
clearInterval(_self.$timer);
|
||||
this.$timer = setInterval(function(){
|
||||
_self.session.setScrollTop(steps[i]);
|
||||
|
||||
if (++i == STEPS + 1)
|
||||
clearInterval(_self.$timer);
|
||||
}, 10);
|
||||
}
|
||||
else {
|
||||
this.session.setScrollTop(offset);
|
||||
}
|
||||
};
|
||||
|
||||
this.scrollToY = function(scrollTop) {
|
||||
|
|
@ -814,7 +855,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
this._loadTheme = function(name, callback) {
|
||||
if (!config.get("packaged"))
|
||||
return callback();
|
||||
|
||||
|
||||
var base = name.split("/").pop();
|
||||
var filename = config.get("themePath") + "/theme-" + base + config.get("suffix");
|
||||
net.loadScript(filename, callback);
|
||||
|
|
@ -826,14 +867,14 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.$themeValue = theme;
|
||||
if (!theme || typeof theme == "string") {
|
||||
var moduleName = theme || "ace/theme/textmate";
|
||||
|
||||
|
||||
var module;
|
||||
try {
|
||||
module = require(moduleName);
|
||||
} catch (e) {};
|
||||
if (module)
|
||||
return afterLoad(module);
|
||||
|
||||
|
||||
_self._loadTheme(moduleName, function() {
|
||||
require([theme], function(module) {
|
||||
if (_self.$themeValue !== theme)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue