just some thoughts on approaches

This commit is contained in:
John McLear 2020-12-27 23:39:20 +00:00
parent e051f2f2f7
commit f6d9c7e705
2 changed files with 19 additions and 39 deletions

View file

@ -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])];
};