fix main > article pointer event

This commit is contained in:
isUnknown 2024-12-02 17:31:52 +01:00
parent 7cda66f837
commit 9aee1ad5b5
3 changed files with 47 additions and 23 deletions

View file

@ -2,6 +2,10 @@ main {
pointer-events: none; pointer-events: none;
} }
main article {
pointer-events: all;
}
.page-cover > * { .page-cover > * {
pointer-events: all; pointer-events: all;
} }

64
assets/dist/script.js vendored
View file

@ -8,16 +8,37 @@ function getUnit(id) {
var pxUnit = remUnit * remFactor; var pxUnit = remUnit * remFactor;
return pxUnit; return pxUnit;
} }
function throttle(callback, limit) {
var waiting = false; // Throttle found here : https://gist.github.com/ionurboz/51b505ee3281cd713747b4a84d69f434
function throttle(func, wait, options) {
var context, args, result;
var timeout = null;
var previous = 0;
if (!options) options = {};
var later = function later() {
previous = options.leading === false ? 0 : Date.now();
timeout = null;
result = func.apply(context, args);
if (!timeout) context = args = null;
};
return function () { return function () {
if (!waiting) { var now = Date.now();
callback.apply(this, arguments); if (!previous && options.leading === false) previous = now;
waiting = true; var remaining = wait - (now - previous);
setTimeout(function () { context = this;
waiting = false; args = arguments;
}, limit); if (remaining <= 0 || remaining > wait) {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
previous = now;
result = func.apply(context, args);
if (!timeout) context = args = null;
} else if (!timeout && options.trailing !== false) {
timeout = setTimeout(later, remaining);
} }
return result;
}; };
} }
function setWindowHeightFactor() { function setWindowHeightFactor() {
@ -39,6 +60,13 @@ function toggleLogoState() {
document.querySelector("#main-header").classList.remove("minimized"); document.querySelector("#main-header").classList.remove("minimized");
} }
} }
function toggleFooterState() {
if (scrollY > 90) {
document.querySelector("#main-footer").classList.add("main-footer--background");
} else {
document.querySelector("#main-footer").classList.remove("main-footer--background");
}
}
function fixFootNotes() { function fixFootNotes() {
var footnotes = document.querySelectorAll('a[href^="#sdfootnote"]'); var footnotes = document.querySelectorAll('a[href^="#sdfootnote"]');
footnotes.forEach(function (footnote) { footnotes.forEach(function (footnote) {
@ -63,17 +91,6 @@ function removeAccents(str) {
function slugify(str) { function slugify(str) {
return removeAccents(str.toLowerCase()); return removeAccents(str.toLowerCase());
} }
var subscribeBtn = document.querySelector("#subscribe-btn");
function showSubscribeField(event) {
event.preventDefault();
var button = event.target;
var li = button.parentNode;
var form = li.querySelector("#subscribe-form");
var input = form.querySelector("input");
form.classList.remove("hidden");
button.classList.add("hidden");
input.focus();
}
function subscribe(event) { function subscribe(event) {
event.preventDefault(); event.preventDefault();
var email = document.querySelector("#subscribe-form input"); var email = document.querySelector("#subscribe-form input");
@ -101,9 +118,13 @@ document.addEventListener("DOMContentLoaded", function () {
window.window.scrollTo({ window.window.scrollTo({
top: 0 top: 0
}); });
window.addEventListener("scroll", function () { var handleScroll = throttle(function () {
toggleLogoState(); toggleLogoState();
}); if (window.innerWidth <= 680) {
toggleFooterState();
}
}, 100);
window.addEventListener("scroll", handleScroll);
setWindowHeightFactor(); setWindowHeightFactor();
window.addEventListener("resize", function () { window.addEventListener("resize", function () {
setWindowHeightFactor(); setWindowHeightFactor();
@ -153,5 +174,4 @@ document.addEventListener("DOMContentLoaded", function () {
navOverlay.addEventListener("click", function () { navOverlay.addEventListener("click", function () {
closeNav(); closeNav();
}); });
subscribeBtn.addEventListener("click", showSubscribeField);
}); });

File diff suppressed because one or more lines are too long