save and restore scroll position of song list

This commit is contained in:
2020-06-09 20:28:35 +02:00
parent 634edec169
commit 268c683ad3
6 changed files with 81 additions and 10 deletions

View File

@@ -0,0 +1,25 @@
import {Injectable} from '@angular/core';
import {BehaviorSubject} from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class ScrollService {
private scrollPosition: number;
private scrollSlots = {};
private _restoreScrollPosition$ = new BehaviorSubject<number>(0);
public restoreScrollPosition$ = this._restoreScrollPosition$.asObservable();
public saveScrollPosition(pos: number) {
this.scrollPosition = pos;
}
public storeScrollPositionFor(slot: string) {
this.scrollSlots[slot] = this.scrollPosition;
}
public restoreScrollPositionFor(slot: string) {
const pos = this.scrollSlots[slot];
this._restoreScrollPosition$.next(pos);
}
}