Merge pull request #2218 from jakemcdermott/fix-2159

job output window - improve scrolling behavior
This commit is contained in:
Michael Abashian 2018-06-19 12:51:05 -04:00 committed by GitHub
commit 389ed995d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 23 deletions

View File

@ -82,7 +82,6 @@ function first () {
return slide.getFirst()
.then(() => {
scroll.resetScrollPosition();
scroll.resume();
return $q.resolve();
@ -99,11 +98,9 @@ function previous () {
const initialPosition = scroll.getScrollPosition();
return slide.slideUp()
.then(changed => {
if (changed[0] !== 0 || changed[1] !== 0) {
const currentHeight = scroll.getScrollHeight();
scroll.setScrollPosition((currentHeight / 4) - initialPosition);
}
.then(popHeight => {
const currentHeight = scroll.getScrollHeight();
scroll.setScrollPosition(currentHeight - popHeight + initialPosition);
return $q.resolve();
});
@ -299,7 +296,7 @@ function OutputIndexController (
bufferInit();
status.init(resource);
slide.init(render, resource.events);
slide.init(render, resource.events, scroll);
render.init({ compile, toggles: vm.toggleLineEnabled });
scroll.init({ previous, next });

View File

@ -59,7 +59,7 @@ function getOverlapArray (range, other) {
}
function SlidingWindowService ($q) {
this.init = (storage, api) => {
this.init = (storage, api, { getScrollHeight }) => {
const { prepend, append, shift, pop, deleteRecord } = storage;
const { getMaxCounter, getRange, getFirst, getLast } = api;
@ -78,6 +78,10 @@ function SlidingWindowService ($q) {
deleteRecord,
};
this.hooks = {
getScrollHeight,
};
this.records = {};
this.uuids = {};
this.chain = $q.resolve();
@ -153,7 +157,7 @@ function SlidingWindowService ($q) {
let lines = 0;
for (let i = min; i <= min + count; ++i) {
for (let i = min; i <= max; ++i) {
if (this.records[i]) {
lines += (this.records[i].end_line - this.records[i].start_line);
}
@ -199,6 +203,21 @@ function SlidingWindowService ($q) {
.then(events => this.pushFront(events));
}
if (overlap && overlap[0] < 0) {
this.chain = this.chain.then(() => this.popBack(Math.abs(overlap[0])));
}
if (overlap && overlap[1] < 0) {
this.chain = this.chain.then(() => this.popFront(Math.abs(overlap[1])));
}
let popHeight;
this.chain = this.chain.then(() => {
popHeight = this.hooks.getScrollHeight();
return $q.resolve();
});
if (overlap && overlap[0] > 0) {
const pushBackRange = [head - overlap[0], head];
@ -215,21 +234,8 @@ function SlidingWindowService ($q) {
.then(events => this.pushFront(events));
}
if (overlap && overlap[0] < 0) {
this.chain = this.chain.then(() => this.popBack(Math.abs(overlap[0])));
}
if (overlap && overlap[1] < 0) {
this.chain = this.chain.then(() => this.popFront(Math.abs(overlap[1])));
}
this.chain = this.chain
.then(() => {
const range = this.getRange();
const displacement = [range[0] - head, range[1] - tail];
return $q.resolve(displacement);
});
.then(() => $q.resolve(popHeight));
return this.chain;
};