mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
just some thoughts on approaches
This commit is contained in:
parent
e051f2f2f7
commit
f6d9c7e705
2 changed files with 19 additions and 39 deletions
|
@ -281,10 +281,14 @@ Scroll.prototype.scrollNodeVerticallyIntoView = function (rep, innerHeight) {
|
|||
// So, when the line scrolled gets outside of the viewport we let the browser handle it.
|
||||
const linePosition = caretPosition.getPosition();
|
||||
if (linePosition) {
|
||||
top.console.log('linepos', linePosition);
|
||||
const distanceOfTopOfViewport = linePosition.top - viewport.top;
|
||||
const distanceOfBottomOfViewport = viewport.bottom - linePosition.bottom;
|
||||
const distanceOfBottomOfViewport = viewport.bottom - linePosition.bottom - 20;
|
||||
// guessed value.. The above line needs to know the height of this element!
|
||||
|
||||
const caretIsAboveOfViewport = distanceOfTopOfViewport < 0;
|
||||
const caretIsBelowOfViewport = distanceOfBottomOfViewport < 0;
|
||||
top.console.log('isbelow', caretIsBelowOfViewport);
|
||||
if (caretIsAboveOfViewport) {
|
||||
const pixelsToScroll =
|
||||
distanceOfTopOfViewport - this._getPixelsRelativeToPercentageOfViewport(innerHeight, true);
|
||||
|
@ -341,6 +345,7 @@ Scroll.prototype.getVisibleLineRange = function (rep) {
|
|||
|
||||
Scroll.prototype.getVisibleCharRange = function (rep) {
|
||||
const lineRange = this.getVisibleLineRange(rep);
|
||||
top.console.log(rep.lines);
|
||||
return [rep.lines.offsetOfIndex(lineRange[0]), rep.lines.offsetOfIndex(lineRange[1])];
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue