drop savedPosition from scrollBehavior
Anchor links (e.g. /#bundles) still scroll to their target section. Back/forward navigation now lands at the top of the destination instead of restoring the previous scroll y, for predictable arrivals. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4
dist/index.html
vendored
4
dist/index.html
vendored
@@ -12,14 +12,14 @@
|
||||
href="https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,200;0,9..144,400;0,9..144,600;0,9..144,700;1,9..144,200;1,9..144,400;1,9..144,600&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<script type="module" crossorigin src="/assets/index-CduAjTXZ.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-D9f5bl7S.js"></script>
|
||||
<link rel="modulepreload" crossorigin href="/assets/_plugin-vue_export-helper-BOai-rQB.js">
|
||||
<link rel="modulepreload" crossorigin href="/assets/preload-helper-DzyYoeor.js">
|
||||
<link rel="modulepreload" crossorigin href="/assets/runtime-core.esm-bundler-DTXUv7Wx.js">
|
||||
<link rel="modulepreload" crossorigin href="/assets/runtime-dom.esm-bundler-BrsyFPJA.js">
|
||||
<link rel="modulepreload" crossorigin href="/assets/pinia-D94NEbtV.js">
|
||||
<link rel="modulepreload" crossorigin href="/assets/vue-router-Cyqru1db.js">
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-CQUnoPmi.css">
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-Dmvci0KL.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
@@ -158,20 +158,14 @@ const routes = [
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes,
|
||||
// Anchor-aware scroll: navigating to `/shop#care` scrolls to the
|
||||
// #care section rather than resetting to top. `el: ...` lets the
|
||||
// router run the browser's own findElementBySelector, so the
|
||||
// ShopPage sections' `scroll-mt-[calc(var(--nav-h)+1rem)]` offset
|
||||
// handles the sticky-nav clearance declaratively. `savedPosition`
|
||||
// honours back/forward navigation — clicking the browser's back
|
||||
// button (or the in-page back link via router.back()) restores the
|
||||
// exact scroll y the user had on the previous page, so deep-linking
|
||||
// into a product detail and returning lands them where they left
|
||||
// off in the shop list.
|
||||
scrollBehavior(to, _from, savedPosition) {
|
||||
if (savedPosition) return savedPosition
|
||||
// Hash nav jumps instantly — smooth scrolling between positions can
|
||||
// trigger motion sickness, so the whole site uses instant jumps.
|
||||
// Anchor-aware scroll: navigating to `/#bundles` or `/shop#care`
|
||||
// scrolls to that section rather than resetting to top. Each
|
||||
// section's `scroll-mt-[calc(var(--nav-h)+1rem)]` offset handles
|
||||
// the sticky-nav clearance. Back/forward navigation always returns
|
||||
// to the top of the destination — `savedPosition` is intentionally
|
||||
// not honoured so users land at a predictable position rather than
|
||||
// wherever they last scrolled to.
|
||||
scrollBehavior(to) {
|
||||
if (to.hash) return { el: to.hash }
|
||||
return { top: 0 }
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user