From e756cfae94369e6a3c63b0df0b2525660164be88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 20 Nov 2020 00:11:13 +0100 Subject: [PATCH] fix anchor navigation for safari --- docs/gridsome.client.js | 5 ++++- docs/src/layouts/App/base.scss | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/gridsome.client.js b/docs/gridsome.client.js index 6c5bcc172..f0a90ebb4 100644 --- a/docs/gridsome.client.js +++ b/docs/gridsome.client.js @@ -13,7 +13,10 @@ export default function (Vue, options, context) { setTimeout(() => { const element = document.getElementById(to.hash.substr(1)) const top = element.offsetTop - const offset = parseFloat(getComputedStyle(element).scrollMarginTop) + const offset = parseFloat( + getComputedStyle(element).scrollMarginTop + || getComputedStyle(element).scrollSnapMarginTop, + ) window.scrollTo(0, top - offset) }, 0) diff --git a/docs/src/layouts/App/base.scss b/docs/src/layouts/App/base.scss index 0f0542b7d..ccaf4fa71 100644 --- a/docs/src/layouts/App/base.scss +++ b/docs/src/layouts/App/base.scss @@ -61,6 +61,7 @@ body { *[id] { scroll-margin-top: 6rem; + scroll-snap-margin-top: 6rem; } button {