commit c4714f750a0a0d2faa5d5511a274c9b6eb93bfe5
parent f5694c06aad743f2229f013752f2fc0143d3549f
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Fri, 12 Jul 2024 18:05:30 +0200
fix: scroll via js
Diffstat:
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/index.php b/index.php
@@ -149,11 +149,12 @@
foreach ($searchcats as $category => $searchids) {
?>
- <details id="<?php echo $category; ?>">
+ <details
+ id="<?php echo $category; ?>"
+ onclick="scroll_to('<?php echo $category; ?>');"
+ >
<summary>
- <a href="#<?php echo $category; ?>">
<?php echo $categories[$category]["name"]; ?>
- </a>
</summary>
<table>
<tr>
@@ -208,5 +209,23 @@
}
</script>
+ <!-- Script to scroll entire category table into view -->
+ <script>
+ scroll_to = function(id) {
+ var obj = document.querySelector('#' + id);
+ // use a delay of 1ms to the object may already be expanded
+ setTimeout(
+ function() {
+ obj.scrollIntoView({
+ behavior: "smooth",
+ block: "start",
+ inline: "nearest"
+ });
+ },
+ 1
+ );
+ }
+ </script>
+
</html>