mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-14 03:54:46 +00:00
cancel navigation if overtaken by a second navigation - fixes #48
This commit is contained in:
@@ -35,10 +35,14 @@ function select_route(url) {
|
||||
}
|
||||
}
|
||||
|
||||
function render(Component, data, scroll) {
|
||||
let current_token;
|
||||
|
||||
function render(Component, data, scroll, token) {
|
||||
Promise.resolve(
|
||||
Component.preload ? Component.preload(data) : {}
|
||||
).then(preloaded => {
|
||||
if (current_token !== token) return;
|
||||
|
||||
if (component) {
|
||||
component.destroy();
|
||||
} else {
|
||||
@@ -83,7 +87,7 @@ function navigate(url, id) {
|
||||
}
|
||||
|
||||
selected.route.load().then(mod => {
|
||||
render(mod.default, selected.data, scroll_history[id]);
|
||||
render(mod.default, selected.data, scroll_history[id], current_token = {});
|
||||
});
|
||||
|
||||
cid = id;
|
||||
|
||||
Reference in New Issue
Block a user