mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-08 03:02:03 +01:00
include proposed fix
This commit is contained in:
parent
1f667f86ef
commit
f0a9e6832f
2 changed files with 7 additions and 16 deletions
|
@ -2219,7 +2219,6 @@ function Ace2Inner() {
|
||||||
if (!docTextChanged) {
|
if (!docTextChanged) {
|
||||||
const isScrollableEvent = !isPadLoading(currentCallStack.type) && isScrollableEditEvent(currentCallStack.type);
|
const isScrollableEvent = !isPadLoading(currentCallStack.type) && isScrollableEditEvent(currentCallStack.type);
|
||||||
const innerHeight = getInnerHeight();
|
const innerHeight = getInnerHeight();
|
||||||
// CAKE WTF?!
|
|
||||||
scroll.scrollWhenCaretIsInTheLastLineOfViewportWhenNecessary(rep, isScrollableEvent, innerHeight*2);
|
scroll.scrollWhenCaretIsInTheLastLineOfViewportWhenNecessary(rep, isScrollableEvent, innerHeight*2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ function Scroll(outerWin) {
|
||||||
|
|
||||||
Scroll.prototype.scrollWhenCaretIsInTheLastLineOfViewportWhenNecessary =
|
Scroll.prototype.scrollWhenCaretIsInTheLastLineOfViewportWhenNecessary =
|
||||||
function (rep, isScrollableEvent, innerHeight) {
|
function (rep, isScrollableEvent, innerHeight) {
|
||||||
top.console.log("scrollWhenCaretIsInTheLastLineOfViewportWhenNecessary");
|
|
||||||
// are we placing the caret on the line at the bottom of viewport?
|
// 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?
|
// And if so, do we need to scroll the editor, as defined on the settings.json?
|
||||||
const shouldScrollWhenCaretIsAtBottomOfViewport =
|
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
|
// 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.
|
// other lines after caretLine(), and all of them are out of viewport.
|
||||||
Scroll.prototype._isCaretAtTheBottomOfViewport = function (rep) {
|
Scroll.prototype._isCaretAtTheBottomOfViewport = function (rep) {
|
||||||
top.console.log("_isCaretAtTheBottomOfViewport");
|
|
||||||
// computing a line position using getBoundingClientRect() is expensive.
|
// computing a line position using getBoundingClientRect() is expensive.
|
||||||
// (obs: getBoundingClientRect() is called on caretPosition.getPosition())
|
// (obs: getBoundingClientRect() is called on caretPosition.getPosition())
|
||||||
// To avoid that, we only call this function when it is possible that the
|
// 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) {
|
Scroll.prototype._isLinePartiallyVisibleOnViewport = function (lineNumber, rep) {
|
||||||
top.console.log('_isLinePartiallyVisibleOnViewport');
|
|
||||||
const lineNode = rep.lines.atIndex(lineNumber);
|
const lineNode = rep.lines.atIndex(lineNumber);
|
||||||
const linePosition = this._getLineEntryTopBottom(lineNode);
|
const linePosition = this._getLineEntryTopBottom(lineNode);
|
||||||
const lineTop = linePosition.top;
|
const lineTop = linePosition.top;
|
||||||
|
@ -231,7 +228,6 @@ Scroll.prototype._getPixelsToScrollWhenUserPressesArrowUp = function (innerHeigh
|
||||||
};
|
};
|
||||||
|
|
||||||
Scroll.prototype._scrollYPage = function (pixelsToScroll) {
|
Scroll.prototype._scrollYPage = function (pixelsToScroll) {
|
||||||
top.console.log("scrollYPage");
|
|
||||||
const durationOfAnimationToShowFocusline = this.scrollSettings.duration;
|
const durationOfAnimationToShowFocusline = this.scrollSettings.duration;
|
||||||
if (durationOfAnimationToShowFocusline) {
|
if (durationOfAnimationToShowFocusline) {
|
||||||
this._scrollYPageWithAnimation(pixelsToScroll, durationOfAnimationToShowFocusline);
|
this._scrollYPageWithAnimation(pixelsToScroll, durationOfAnimationToShowFocusline);
|
||||||
|
@ -278,7 +274,6 @@ Scroll.prototype._triggerScrollWithAnimation =
|
||||||
// besides of scrolling the minimum needed to be visible, it scrolls additionally
|
// besides of scrolling the minimum needed to be visible, it scrolls additionally
|
||||||
// (viewport height * scrollAmountWhenFocusLineIsOutOfViewport) pixels
|
// (viewport height * scrollAmountWhenFocusLineIsOutOfViewport) pixels
|
||||||
Scroll.prototype.scrollNodeVerticallyIntoView = function (rep, innerHeight) {
|
Scroll.prototype.scrollNodeVerticallyIntoView = function (rep, innerHeight) {
|
||||||
top.console.log("scrollNodeVerticallyIntoView");
|
|
||||||
const viewport = this._getViewPortTopBottom();
|
const viewport = this._getViewPortTopBottom();
|
||||||
|
|
||||||
// when the selection changes outside of the viewport the browser automatically scrolls the line
|
// 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();
|
const linePosition = caretPosition.getPosition();
|
||||||
if (linePosition) {
|
if (linePosition) {
|
||||||
const distanceOfTopOfViewport = linePosition.top - viewport.top;
|
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 caretIsAboveOfViewport = distanceOfTopOfViewport < 0;
|
||||||
const caretIsBelowOfViewport = true;
|
const caretIsBelowOfViewport = distanceOfBottomOfViewport < 0;
|
||||||
if (caretIsAboveOfViewport) {
|
if (caretIsAboveOfViewport) {
|
||||||
const pixelsToScroll =
|
const pixelsToScroll =
|
||||||
distanceOfTopOfViewport - this._getPixelsRelativeToPercentageOfViewport(innerHeight, true);
|
distanceOfTopOfViewport - this._getPixelsRelativeToPercentageOfViewport(innerHeight, true);
|
||||||
this._scrollYPage(pixelsToScroll);
|
this._scrollYPage(pixelsToScroll);
|
||||||
} else if (caretIsBelowOfViewport) {
|
} 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);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue