implement sapper no scroll

This commit is contained in:
Daniil Khanin
2018-10-05 00:13:08 +03:00
parent 3026e7c36e
commit 05b702938f
2 changed files with 6 additions and 4 deletions

View File

@@ -106,16 +106,17 @@ export function scroll_state() {
};
}
export function navigate(target: Target, id: number): Promise<any> {
export function navigate(target: Target, id: number, has_scroll = false): Promise<any> {
if (id) {
// popstate or initial navigation
cid = id;
} else {
const current_scroll = scroll_state()
// clicked on a link. preserve scroll state
scroll_history[cid] = scroll_state();
scroll_history[cid] = current_scroll;
id = cid = ++uid;
scroll_history[cid] = { x: 0, y: 0 };
scroll_history[cid] = has_scroll ? current_scroll : { x: 0, y: 0 };
}
cid = id;