mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
Fixed a bug where loading page on book reader wouldn't scroll to last position (#907)
This commit is contained in:
parent
6afbf5f08f
commit
426cb7f0be
@ -301,8 +301,6 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
.pipe(debounceTime(200), takeUntil(this.onDestroy)).subscribe((event) => {
|
||||
if (this.isLoading) return;
|
||||
|
||||
console.log('Scroll');
|
||||
|
||||
// Highlight the current chapter we are on
|
||||
if (Object.keys(this.pageAnchors).length !== 0) {
|
||||
// get the height of the document so we can capture markers that are halfway on the document viewport
|
||||
@ -745,9 +743,9 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
if (part !== undefined && part !== '') {
|
||||
this.scrollTo(part);
|
||||
} else if (scrollTop !== undefined && scrollTop !== 0) {
|
||||
this.scrollService.scrollTo(scrollTop);
|
||||
this.scrollService.scrollTo(scrollTop, this.reader.nativeElement);
|
||||
} else {
|
||||
this.scrollService.scrollTo(0);
|
||||
this.scrollService.scrollTo(0, this.reader.nativeElement);
|
||||
}
|
||||
}
|
||||
|
||||
@ -971,7 +969,7 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
if (element === null) return;
|
||||
|
||||
this.scrollService.scrollTo(element.getBoundingClientRect().top + window.pageYOffset + TOP_OFFSET);
|
||||
this.scrollService.scrollTo(element.getBoundingClientRect().top + window.pageYOffset + TOP_OFFSET, this.reader.nativeElement);
|
||||
}
|
||||
|
||||
toggleClickToPaginate() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ElementRef, Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -13,8 +13,8 @@ export class ScrollService {
|
||||
|| document.body.scrollTop || 0);
|
||||
}
|
||||
|
||||
scrollTo(top: number) {
|
||||
window.scroll({
|
||||
scrollTo(top: number, el: Element | Window = window) {
|
||||
el.scroll({
|
||||
top: top,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user