handle hscrollbar change during autoresize
This commit is contained in:
parent
0db985a3d7
commit
93c39ca5b0
2 changed files with 19 additions and 8 deletions
|
|
@ -7,14 +7,13 @@
|
|||
<style type="text/css" media="screen">
|
||||
|
||||
.ace_editor {
|
||||
position: relative !important;
|
||||
border: 1px solid lightgray;
|
||||
margin: auto;
|
||||
height: 200px;
|
||||
width: 80%;
|
||||
}
|
||||
.scrollmargin {
|
||||
height: 100px;
|
||||
height: 80px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -24,6 +23,8 @@
|
|||
<div class="scrollmargin"></div>
|
||||
<pre id="editor2">minHeight = 2 lines</pre>
|
||||
<div class="scrollmargin"></div>
|
||||
<pre id="editor3" style="width: 40%;"></pre>
|
||||
<div class="scrollmargin"></div>
|
||||
<pre id="editor"></pre>
|
||||
|
||||
<script src="kitchen-sink/require.js"></script>
|
||||
|
|
@ -46,6 +47,14 @@ require(["ace/ace"], function(ace) {
|
|||
editor2.setOption("maxLines", 30);
|
||||
editor2.setOption("minLines", 2);
|
||||
|
||||
var editor = ace.edit("editor3");
|
||||
editor.setOptions({
|
||||
maxLines: 100,
|
||||
autoScrollEditorIntoView: true,
|
||||
maxLines: 8
|
||||
});
|
||||
editor.renderer.setScrollMargin(10, 10, 10, 10);
|
||||
|
||||
var editor = ace.edit("editor");
|
||||
editor.setTheme("ace/theme/tomorrow");
|
||||
editor.session.setMode("ace/mode/html");
|
||||
|
|
|
|||
|
|
@ -919,6 +919,8 @@ var VirtualRenderer = function(container, theme) {
|
|||
(this.$minLines||1) * this.lineHeight,
|
||||
Math.min(maxHeight, height)
|
||||
) + this.scrollMargin.v + (this.$extraHeight || 0);
|
||||
if (this.$horizScroll)
|
||||
desiredHeight += this.scrollBarH.getHeight();
|
||||
var vScroll = height > maxHeight;
|
||||
|
||||
if (desiredHeight != this.desiredHeight ||
|
||||
|
|
@ -939,9 +941,6 @@ var VirtualRenderer = function(container, theme) {
|
|||
};
|
||||
|
||||
this.$computeLayerConfig = function() {
|
||||
if (this.$maxLines && this.lineHeight > 1)
|
||||
this.$autosize();
|
||||
|
||||
var session = this.session;
|
||||
var size = this.$size;
|
||||
|
||||
|
|
@ -949,9 +948,6 @@ var VirtualRenderer = function(container, theme) {
|
|||
var screenLines = this.session.getScreenLength();
|
||||
var maxHeight = screenLines * this.lineHeight;
|
||||
|
||||
var offset = this.scrollTop % this.lineHeight;
|
||||
var minHeight = size.scrollerHeight + this.lineHeight;
|
||||
|
||||
var longestLine = this.$getLongestLine();
|
||||
|
||||
var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible ||
|
||||
|
|
@ -962,6 +958,12 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.$horizScroll = horizScroll;
|
||||
this.scrollBarH.setVisible(horizScroll);
|
||||
}
|
||||
// autoresize only after updating hscroll to include scrollbar height in desired height
|
||||
if (this.$maxLines && this.lineHeight > 1)
|
||||
this.$autosize();
|
||||
|
||||
var offset = this.scrollTop % this.lineHeight;
|
||||
var minHeight = size.scrollerHeight + this.lineHeight;
|
||||
|
||||
var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd
|
||||
? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue