Skip to content

Commit

Permalink
fix: anchor link need decode (CaiJimmy#719)
Browse files Browse the repository at this point in the history
  • Loading branch information
GGXXLL authored Dec 5, 2022
1 parent ff7a56a commit 3ff06fe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions assets/ts/smoothAnchors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ function setupSmoothAnchors() {
aElement.addEventListener("click", clickEvent => {
clickEvent.preventDefault();

const targetId = aElement.getAttribute("href").substring(1),
target = document.getElementById(targetId) as HTMLElement,
const targetId = decodeURI(aElement.getAttribute("href").substring(1)),
target = document.getElementById(targetId) as HTMLElement,
offset = target.getBoundingClientRect().top - document.documentElement.getBoundingClientRect().top;

window.history.pushState({}, "", aElement.getAttribute("href"));
Expand Down

0 comments on commit 3ff06fe

Please sign in to comment.