This commit is contained in:
ポール ウェッブ 2018-10-09 14:15:53 -05:00
parent 17e13faef0
commit 299b40fcfb

View file

@ -41,7 +41,8 @@ document.querySelectorAll("a[href^='#']").forEach(anchor => {
anchor.addEventListener("click", event => { anchor.addEventListener("click", event => {
event.preventDefault(); event.preventDefault();
const element = event.target.href.split("#").pop(); const element = event.target.href.split("#").pop()
.toLowerCase();
let elementOffset; let elementOffset;
if (document.getElementById(element)) { if (document.getElementById(element)) {
@ -76,7 +77,8 @@ document.querySelector("[data-action='subscribe to newsletter']").onclick = () =
function scrollToElementOnLoad() { function scrollToElementOnLoad() {
if (window.location.href.includes("#")) { if (window.location.href.includes("#")) {
setTimeout(() => { // give page time to breathe setTimeout(() => { // give page time to breathe
const element = window.location.href.split("#").pop(); const element = window.location.href.split("#").pop()
.toLowerCase();
let elementOffset; let elementOffset;
if (document.getElementById(element)) { if (document.getElementById(element)) {