Skip to content

Commit c287613

Browse files
committed
feat: allow skipping scrolling on partial navigation
1 parent c06a84e commit c287613

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/fresh/src/runtime/client/partials.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { parse } from "../../jsonify/parse.ts";
2525
import { INTERNAL_PREFIX, PARTIAL_SEARCH_PARAM } from "../../constants.ts";
2626

2727
export const PARTIAL_ATTR = "f-partial";
28+
export const PARTIAL_NO_SCROLL_ATTR = "f-dont-scroll";
2829

2930
class NoPartialsError extends Error {}
3031

@@ -170,7 +171,9 @@ document.addEventListener("click", async (e) => {
170171
await fetchPartials(nextUrl, partialUrl, true);
171172
updateLinks(nextUrl);
172173
});
173-
scrollTo({ left: 0, top: 0, behavior: "instant" });
174+
if (!el.hasAttribute(PARTIAL_NO_SCROLL_ATTR)) {
175+
scrollTo({ left: 0, top: 0, behavior: "instant" });
176+
}
174177
} finally {
175178
if (indicator !== undefined) {
176179
indicator.value = false;

0 commit comments

Comments
 (0)