Cursor-Placement (TODO:, mobile, bilder, pdf)

This commit is contained in:
Simon Martens
2023-02-07 23:53:02 +01:00
parent f94d53f9b5
commit 62fdd332dc
4 changed files with 20 additions and 5 deletions

View File

@@ -81,6 +81,16 @@
}
}
function isInViewport(element) {
const rect = element.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
);
}
// Scripts for filtering lists
let dictionary = [];
let categories = [];
@@ -272,7 +282,11 @@
categories = document
.getElementById("list")
.getElementsByClassName("category");
{# $("input[name='keyword']").focus(); #}
var searchinput = document.querySelector("input[name='keyword']");
if (searchinput !== null && isInViewport(searchinput)) {
$("input[name='keyword']").focus();
}
$("input[name='keyword']").keyup(search);
// Scrolling & List updating
@@ -289,7 +303,7 @@
window.onscroll = function () {
var scrollPosition = document.documentElement.scrollTop || document.body.scrollTop;
for (i in sections) {
if (sections[i] <= scrollPosition) {
if (sections[i] <= scrollPosition + 60) {
var opt = select.querySelector('option[value="#' + i + '"]');
if (opt !== null) {
opt.selected = true;