Merge pull request #2544 from jakemcdermott/fix-2233

fix output double-scroll bug and initial output page numbers
This commit is contained in:
Jake McDermott
2018-07-16 12:32:52 -04:00
committed by GitHub
2 changed files with 20 additions and 10 deletions

View File

@@ -97,11 +97,15 @@ function first () {
} }
function next () { function next () {
return slide.getNext(); scroll.pause();
return slide.getNext()
.finally(() => scroll.resume());
} }
function previous () { function previous () {
unfollow(); unfollow();
scroll.pause();
const initialPosition = scroll.getScrollPosition(); const initialPosition = scroll.getScrollPosition();
@@ -111,7 +115,8 @@ function previous () {
scroll.setScrollPosition(currentHeight - popHeight + initialPosition); scroll.setScrollPosition(currentHeight - popHeight + initialPosition);
return $q.resolve(); return $q.resolve();
}); })
.finally(() => scroll.resume());
} }
function last () { function last () {

View File

@@ -27,6 +27,7 @@ function PageService ($q) {
this.records = {}; this.records = {};
this.uuids = {}; this.uuids = {};
this.state = { this.state = {
head: 0, head: 0,
tail: 0, tail: 0,
@@ -35,16 +36,18 @@ function PageService ($q) {
this.chain = $q.resolve(); this.chain = $q.resolve();
}; };
this.pushFront = results => { this.pushFront = (results, key) => {
if (!results) { if (!results) {
return $q.resolve(); return $q.resolve();
} }
return this.storage.append(results) return this.storage.append(results)
.then(() => { .then(() => {
this.records[++this.state.tail] = {}; const tail = key || ++this.state.tail;
this.records[tail] = {};
results.forEach(({ counter, start_line, end_line, uuid }) => { results.forEach(({ counter, start_line, end_line, uuid }) => {
this.records[this.state.tail][counter] = { start_line, end_line }; this.records[tail][counter] = { start_line, end_line };
this.uuids[counter] = uuid; this.uuids[counter] = uuid;
}); });
@@ -52,16 +55,18 @@ function PageService ($q) {
}); });
}; };
this.pushBack = results => { this.pushBack = (results, key) => {
if (!results) { if (!results) {
return $q.resolve(); return $q.resolve();
} }
return this.storage.prepend(results) return this.storage.prepend(results)
.then(() => { .then(() => {
this.records[--this.state.head] = {}; const head = key || --this.state.head;
this.records[head] = {};
results.forEach(({ counter, start_line, end_line, uuid }) => { results.forEach(({ counter, start_line, end_line, uuid }) => {
this.records[this.state.head][counter] = { start_line, end_line }; this.records[head][counter] = { start_line, end_line };
this.uuids[counter] = uuid; this.uuids[counter] = uuid;
}); });
@@ -216,7 +221,7 @@ function PageService ($q) {
this.state.head = lastPage; this.state.head = lastPage;
this.state.tail = lastPage; this.state.tail = lastPage;
return this.pushBack(events); return this.pushBack(events, lastPage);
}) })
.then(() => this.getPrevious()); .then(() => this.getPrevious());
@@ -226,7 +231,7 @@ function PageService ($q) {
this.state.head = 1; this.state.head = 1;
this.state.tail = 1; this.state.tail = 1;
return this.pushBack(events); return this.pushBack(events, 1);
}) })
.then(() => this.getNext()); .then(() => this.getNext());