[FIX] Seite im IE falsch dargestellt
This commit is contained in:
parent
a5ee3ace74
commit
4314fd4214
81
script.js
81
script.js
@ -10,31 +10,80 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var mailcypts = document.querySelectorAll(".cryptmail");
|
var mailcypts = document.querySelectorAll(".cryptmail");
|
||||||
mailcypts.forEach(element => {
|
for (var i = 0; i < mailcypts.length; i++) {
|
||||||
element.onclick = function () {
|
mailcypts[i].onclick = function () {
|
||||||
window.location.href = 'mailto:' + this.dataset.name + '@' + this.dataset.domain + '.' + this.dataset.tld;
|
window.location.href = 'mailto:' + this.dataset.name + '@' + this.dataset.domain + '.' + this.dataset.tld;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
var hashAnchors = document.querySelectorAll("a[href^='#']");
|
var hashAnchors = document.querySelectorAll("a[href^='#']");
|
||||||
hashAnchors.forEach(element => {
|
for (var i = 0; i < hashAnchors.length; i++) {
|
||||||
element.onclick = function () {
|
hashAnchors[i].onclick = function () {
|
||||||
var target = this.getAttribute("href");
|
var target = this.getAttribute("href");
|
||||||
scrollToElement(target);
|
scrollToElement(target);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function scrollToElement(name) {
|
const navbarScrollOffset = -48;
|
||||||
var elementToScrollTo = document.querySelector(name);
|
// native smooth scrolling for Chrome, Firefox & Opera
|
||||||
var top = elementToScrollTo.getBoundingClientRect().top + window.pageYOffset - 48;
|
// @see: https://caniuse.com/#feat=css-scroll-behavior
|
||||||
|
const nativeSmoothScrollTo = function (elem) {
|
||||||
|
window.scroll({
|
||||||
|
behavior: 'smooth',
|
||||||
|
left: 0,
|
||||||
|
top: elem.getBoundingClientRect().top + window.pageYOffset + navbarScrollOffset
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
window.scrollTo({
|
// polyfilled smooth scrolling for IE, Edge & Safari
|
||||||
top: top,
|
const smoothScrollTo = function (to, duration) {
|
||||||
behavior: "smooth"
|
const element = document.scrollingElement || document.documentElement,
|
||||||
})
|
start = element.scrollTop,
|
||||||
}
|
change = to - start,
|
||||||
|
startDate = +new Date();
|
||||||
|
|
||||||
|
// t = current time
|
||||||
|
// b = start value
|
||||||
|
// c = change in value
|
||||||
|
// d = duration
|
||||||
|
const easeInOutQuad = function (t, b, c, d) {
|
||||||
|
t /= d / 2;
|
||||||
|
if (t < 1) return c / 2 * t * t + b;
|
||||||
|
t--;
|
||||||
|
return -c / 2 * (t * (t - 2) - 1) + b;
|
||||||
|
};
|
||||||
|
|
||||||
|
const animateScroll = function () {
|
||||||
|
const currentDate = +new Date();
|
||||||
|
const currentTime = currentDate - startDate;
|
||||||
|
element.scrollTop = parseInt(easeInOutQuad(currentTime, start, change, duration));
|
||||||
|
if (currentTime < duration) {
|
||||||
|
requestAnimationFrame(animateScroll);
|
||||||
|
} else {
|
||||||
|
element.scrollTop = to;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
animateScroll();
|
||||||
|
};
|
||||||
|
|
||||||
|
// detect support for the behavior property in ScrollOptions
|
||||||
|
const supportsNativeSmoothScroll = 'scrollBehavior' in document.documentElement.style;
|
||||||
|
|
||||||
|
// smooth scrolling stub
|
||||||
|
const scrollToElement = function (elemSelector) {
|
||||||
|
if (!elemSelector) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const elem = document.querySelector(elemSelector);
|
||||||
|
if (elem) {
|
||||||
|
if (supportsNativeSmoothScroll) {
|
||||||
|
nativeSmoothScrollTo(elem);
|
||||||
|
} else {
|
||||||
|
smoothScrollTo(elem.offsetTop + navbarScrollOffset, 600);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
x
Reference in New Issue
Block a user