mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-08 03:02:03 +01:00
ah so a set timeout is required?
This commit is contained in:
parent
ef2a929016
commit
1f667f86ef
2 changed files with 15 additions and 9 deletions
|
@ -2219,7 +2219,8 @@ 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();
|
||||||
scroll.scrollWhenCaretIsInTheLastLineOfViewportWhenNecessary(rep, isScrollableEvent, innerHeight);
|
// CAKE WTF?!
|
||||||
|
scroll.scrollWhenCaretIsInTheLastLineOfViewportWhenNecessary(rep, isScrollableEvent, innerHeight*2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -2792,10 +2793,6 @@ function Ace2Inner() {
|
||||||
if (keyCode == 13 && browser.opera && (type == 'keypress')) {
|
if (keyCode == 13 && browser.opera && (type == 'keypress')) {
|
||||||
return; // This stops double enters in Opera but double Tabs still show on single tab keypress, adding keyCode == 9 to this doesn't help as the event is fired twice
|
return; // This stops double enters in Opera but double Tabs still show on single tab keypress, adding keyCode == 9 to this doesn't help as the event is fired twice
|
||||||
}
|
}
|
||||||
// Ensure caret is always on focus on enter key
|
|
||||||
if (keyCode === 13 && (type === 'keypress')) {
|
|
||||||
fixView();
|
|
||||||
}
|
|
||||||
let specialHandled = false;
|
let specialHandled = false;
|
||||||
const isTypeForSpecialKey = ((browser.safari || browser.chrome || browser.firefox) ? (type == 'keydown') : (type == 'keypress'));
|
const isTypeForSpecialKey = ((browser.safari || browser.chrome || browser.firefox) ? (type == 'keydown') : (type == 'keypress'));
|
||||||
const isTypeForCmdKey = ((browser.safari || browser.chrome || browser.firefox) ? (type == 'keydown') : (type == 'keypress'));
|
const isTypeForCmdKey = ((browser.safari || browser.chrome || browser.firefox) ? (type == 'keydown') : (type == 'keypress'));
|
||||||
|
|
|
@ -21,6 +21,7 @@ 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 =
|
||||||
|
@ -58,6 +59,7 @@ 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
|
||||||
|
@ -81,6 +83,7 @@ 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;
|
||||||
|
@ -228,6 +231,7 @@ 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);
|
||||||
|
@ -274,6 +278,7 @@ 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
|
||||||
|
@ -284,15 +289,19 @@ Scroll.prototype.scrollNodeVerticallyIntoView = function (rep, innerHeight) {
|
||||||
const distanceOfTopOfViewport = linePosition.top - viewport.top;
|
const distanceOfTopOfViewport = linePosition.top - viewport.top;
|
||||||
const distanceOfBottomOfViewport = viewport.bottom - linePosition.bottom;
|
const distanceOfBottomOfViewport = viewport.bottom - linePosition.bottom;
|
||||||
const caretIsAboveOfViewport = distanceOfTopOfViewport < 0;
|
const caretIsAboveOfViewport = distanceOfTopOfViewport < 0;
|
||||||
const caretIsBelowOfViewport = distanceOfBottomOfViewport < 0;
|
const caretIsBelowOfViewport = true;
|
||||||
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) {
|
||||||
const pixelsToScroll = -distanceOfBottomOfViewport +
|
top.console.log("caretIsBelowOfViewport")
|
||||||
this._getPixelsRelativeToPercentageOfViewport(innerHeight);
|
setTimeout(function(){
|
||||||
this._scrollYPage(pixelsToScroll);
|
const outer = window.parent;
|
||||||
|
top.console.log(outer.outerHeight);
|
||||||
|
outer.scrollTo(0,outer[0].innerHeight)
|
||||||
|
}, 150);
|
||||||
|
// this._scrollYPageWithoutAnimation(50);
|
||||||
} else {
|
} else {
|
||||||
this.scrollWhenCaretIsInTheLastLineOfViewportWhenNecessary(rep, true, innerHeight);
|
this.scrollWhenCaretIsInTheLastLineOfViewportWhenNecessary(rep, true, innerHeight);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue