mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 03:05:12 +00:00
handle deep links
This commit is contained in:
@@ -177,10 +177,17 @@ export function init(_target, _routes) {
|
||||
inited = true;
|
||||
}
|
||||
|
||||
scroll_history[uid] = scroll_state();
|
||||
setTimeout(() => {
|
||||
const { hash, href } = window.location;
|
||||
|
||||
history.replaceState({ id: uid }, '', window.location.href);
|
||||
navigate(new URL(window.location), uid);
|
||||
const deep_linked = hash && document.querySelector(hash);
|
||||
scroll_history[uid] = deep_linked ?
|
||||
{ x: 0, y: deep_linked.getBoundingClientRect().top } :
|
||||
scroll_state();
|
||||
|
||||
history.replaceState({ id: uid }, '', href);
|
||||
navigate(new URL(window.location), uid);
|
||||
});
|
||||
}
|
||||
|
||||
function which(event) {
|
||||
|
||||
Reference in New Issue
Block a user