@sveltejs/kit 1.0.0-next.196 → 1.0.0-next.197
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/runtime/internal/start.js +35 -40
- package/dist/cli.js +2 -2
- package/package.json +1 -1
|
@@ -656,48 +656,43 @@ class Renderer {
|
|
|
656
656
|
this._init(navigation_result);
|
|
657
657
|
}
|
|
658
658
|
|
|
659
|
-
|
|
659
|
+
const { hash, scroll, keepfocus } = opts || {};
|
|
660
660
|
|
|
661
|
-
if (!
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
if (!keepfocus) {
|
|
667
|
-
document.body.focus();
|
|
668
|
-
}
|
|
661
|
+
if (!keepfocus) {
|
|
662
|
+
getSelection()?.removeAllRanges();
|
|
663
|
+
document.body.focus();
|
|
664
|
+
}
|
|
669
665
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
}
|
|
666
|
+
const old_page_y_offset = Math.round(pageYOffset);
|
|
667
|
+
const old_max_page_y_offset = document.documentElement.scrollHeight - innerHeight;
|
|
668
|
+
|
|
669
|
+
await 0;
|
|
670
|
+
|
|
671
|
+
const new_page_y_offset = Math.round(pageYOffset);
|
|
672
|
+
const new_max_page_y_offset = document.documentElement.scrollHeight - innerHeight;
|
|
673
|
+
|
|
674
|
+
// After `await 0`, the `onMount()` function in the component executed.
|
|
675
|
+
// Check if no scrolling happened on mount.
|
|
676
|
+
const no_scroll_happened =
|
|
677
|
+
// In most cases, we can compare whether `pageYOffset` changed between navigation
|
|
678
|
+
new_page_y_offset === Math.min(old_page_y_offset, new_max_page_y_offset) ||
|
|
679
|
+
// But if the page is scrolled to/near the bottom, the browser would also scroll
|
|
680
|
+
// to/near the bottom of the new page on navigation. Since we can't detect when this
|
|
681
|
+
// behaviour happens, we naively compare by the y offset from the bottom of the page.
|
|
682
|
+
old_max_page_y_offset - old_page_y_offset === new_max_page_y_offset - new_page_y_offset;
|
|
683
|
+
|
|
684
|
+
// If there was no scrolling, we run on our custom scroll handling
|
|
685
|
+
if (no_scroll_happened) {
|
|
686
|
+
const deep_linked = hash && document.getElementById(hash.slice(1));
|
|
687
|
+
if (scroll) {
|
|
688
|
+
scrollTo(scroll.x, scroll.y);
|
|
689
|
+
} else if (deep_linked) {
|
|
690
|
+
// Here we use `scrollIntoView` on the element instead of `scrollTo`
|
|
691
|
+
// because it natively supports the `scroll-margin` and `scroll-behavior`
|
|
692
|
+
// CSS properties.
|
|
693
|
+
deep_linked.scrollIntoView();
|
|
694
|
+
} else {
|
|
695
|
+
scrollTo(0, 0);
|
|
701
696
|
}
|
|
702
697
|
}
|
|
703
698
|
|
package/dist/cli.js
CHANGED
|
@@ -817,7 +817,7 @@ async function launch(port, https) {
|
|
|
817
817
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
|
|
818
818
|
}
|
|
819
819
|
|
|
820
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
820
|
+
const prog = sade('svelte-kit').version('1.0.0-next.197');
|
|
821
821
|
|
|
822
822
|
prog
|
|
823
823
|
.command('dev')
|
|
@@ -982,7 +982,7 @@ async function check_port(port) {
|
|
|
982
982
|
function welcome({ port, host, https, open, loose, allow, cwd }) {
|
|
983
983
|
if (open) launch(port, https);
|
|
984
984
|
|
|
985
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
985
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.197'}\n`));
|
|
986
986
|
|
|
987
987
|
const protocol = https ? 'https:' : 'http:';
|
|
988
988
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|