include proposed fix

This commit is contained in:
John McLear 2021-01-10 15:47:42 +00:00
parent 1f667f86ef
commit f0a9e6832f
2 changed files with 7 additions and 16 deletions

View file

@ -2219,7 +2219,6 @@ function Ace2Inner() {
if (!docTextChanged) {
const isScrollableEvent = !isPadLoading(currentCallStack.type) && isScrollableEditEvent(currentCallStack.type);
const innerHeight = getInnerHeight();
// CAKE WTF?!
scroll.scrollWhenCaretIsInTheLastLineOfViewportWhenNecessary(rep, isScrollableEvent, innerHeight*2);
}

View file

@ -21,7 +21,6 @@ function Scroll(outerWin) {
Scroll.prototype.scrollWhenCaretIsInTheLastLineOfViewportWhenNecessary =
function (rep, isScrollableEvent, innerHeight) {
top.console.log("scrollWhenCaretIsInTheLastLineOfViewportWhenNecessary");
// are we placing the caret on the line at the bottom of viewport?
// And if so, do we need to scroll the editor, as defined on the settings.json?
const shouldScrollWhenCaretIsAtBottomOfViewport =
@ -59,7 +58,6 @@ Scroll.prototype.scrollWhenPressArrowKeys = function (arrowUp, rep, innerHeight)
// if (caretLine() === rep.lines.length() - 1) is not enough. We need to check if there are
// other lines after caretLine(), and all of them are out of viewport.
Scroll.prototype._isCaretAtTheBottomOfViewport = function (rep) {
top.console.log("_isCaretAtTheBottomOfViewport");
// computing a line position using getBoundingClientRect() is expensive.
// (obs: getBoundingClientRect() is called on caretPosition.getPosition())
// To avoid that, we only call this function when it is possible that the
@ -83,7 +81,6 @@ Scroll.prototype._isCaretAtTheBottomOfViewport = function (rep) {
};
Scroll.prototype._isLinePartiallyVisibleOnViewport = function (lineNumber, rep) {
top.console.log('_isLinePartiallyVisibleOnViewport');
const lineNode = rep.lines.atIndex(lineNumber);
const linePosition = this._getLineEntryTopBottom(lineNode);
const lineTop = linePosition.top;
@ -231,7 +228,6 @@ Scroll.prototype._getPixelsToScrollWhenUserPressesArrowUp = function (innerHeigh
};
Scroll.prototype._scrollYPage = function (pixelsToScroll) {
top.console.log("scrollYPage");
const durationOfAnimationToShowFocusline = this.scrollSettings.duration;
if (durationOfAnimationToShowFocusline) {
this._scrollYPageWithAnimation(pixelsToScroll, durationOfAnimationToShowFocusline);
@ -278,7 +274,6 @@ Scroll.prototype._triggerScrollWithAnimation =
// besides of scrolling the minimum needed to be visible, it scrolls additionally
// (viewport height * scrollAmountWhenFocusLineIsOutOfViewport) pixels
Scroll.prototype.scrollNodeVerticallyIntoView = function (rep, innerHeight) {
top.console.log("scrollNodeVerticallyIntoView");
const viewport = this._getViewPortTopBottom();
// when the selection changes outside of the viewport the browser automatically scrolls the line
@ -287,23 +282,20 @@ Scroll.prototype.scrollNodeVerticallyIntoView = function (rep, innerHeight) {
const linePosition = caretPosition.getPosition();
if (linePosition) {
const distanceOfTopOfViewport = linePosition.top - viewport.top;
const distanceOfBottomOfViewport = viewport.bottom - linePosition.bottom;
const distanceOfBottomOfViewport = viewport.bottom - linePosition.bottom - linePosition.height;
const caretIsAboveOfViewport = distanceOfTopOfViewport < 0;
const caretIsBelowOfViewport = true;
const caretIsBelowOfViewport = distanceOfBottomOfViewport < 0;
if (caretIsAboveOfViewport) {
const pixelsToScroll =
distanceOfTopOfViewport - this._getPixelsRelativeToPercentageOfViewport(innerHeight, true);
this._scrollYPage(pixelsToScroll);
} else if (caretIsBelowOfViewport) {
top.console.log("caretIsBelowOfViewport")
setTimeout(function(){
const outer = window.parent;
top.console.log(outer.outerHeight);
outer.scrollTo(0,outer[0].innerHeight)
}, 150);
// this._scrollYPageWithoutAnimation(50);
} else {
this.scrollWhenCaretIsInTheLastLineOfViewportWhenNecessary(rep, true, innerHeight);
// setTimeout is required here as line might not be fully rendered onto the pad
setTimeout(() => {
const outer = window.parent;
outer.scrollTo(0, outer[0].innerHeight)
}, 150);
}
}
};