fix offset calculation if element position is relative and use inset box shadow for highlighting items plus some css fixes

This commit is contained in:
Mario
2025-05-15 07:23:42 +00:00
parent d77d56dfb0
commit 9165f766c2
3 changed files with 24 additions and 4 deletions

View File

@@ -194,7 +194,17 @@ a.wall-item-name-link {
}
.item-highlight {
box-shadow: -.15rem 0 0 0 var(--bs-primary);
position: relative;
}
.item-highlight:after {
content: '';
position: absolute;
pointer-events: none;
box-shadow: inset .15rem 0 0 0 var(--hz-item-highlight);
height: 100%;
width: 100%;
top: 0;
}
.item-highlight-fade {

View File

@@ -756,7 +756,7 @@ function updateConvItems(mode, data) {
if (data_json.includes(bParam_mid) && elem.parentNode.classList.contains('wall-item-sub-thread-wrapper')) {
if (!elem.parentNode.parentNode.classList.contains('toplevel_item')) {
elem.parentNode.parentNode.classList.add('item-highlight');
elem.parentNode.parentNode.style.boxShadow = '-.15rem 0 0 0 ' + stringToHlsColor(JSON.parse(elem.parentNode.parentNode.dataset.b64mids)[0]);
document.documentElement.style.setProperty('--hz-item-highlight', stringToHlsColor(JSON.parse(elem.parentNode.parentNode.dataset.b64mids)[0]));
}
}
@@ -982,7 +982,7 @@ function scrollToItem() {
// Scroll to the target element
let navHeight = document.querySelector('nav') ? document.querySelector('nav').offsetHeight : 0;
window.scrollTo({
top: thread.offsetTop - navHeight,
top: getOffsetTopRelativeToBody(thread) - navHeight,
behavior: 'smooth'
});
@@ -993,6 +993,15 @@ function scrollToItem() {
});
}
function getOffsetTopRelativeToBody(element) {
let offsetTop = 0;
while (element) {
offsetTop += element.offsetTop;
element = element.offsetParent;
}
return offsetTop;
}
function collapseHeight() {
$(".wall-item-content:not('.divmore_checked'), .directory-collapse:not('.divmore_checked')").each(function(i) {
let orgHeight = $(this).outerHeight(true);
@@ -1301,7 +1310,7 @@ function request(id, mid, verb, parent, uuid) {
const wrapper = document.getElementById('thread-wrapper-' + id);
if (!wrapper.classList.contains('toplevel_item')) {
wrapper.classList.add('item-highlight');
wrapper.style.boxShadow = '-.15rem 0 0 0 ' + stringToHlsColor(uuid);
document.documentElement.style.setProperty('--hz-item-highlight', stringToHlsColor(uuid));
}
fetch('/request?verb=' + verb + '&mid=' + mid + '&parent=' + parent + '&module=' + module)

View File

@@ -953,6 +953,7 @@ a .drop-icons:hover {
}
.wall-item-pinned i {
display: inline-block;
transform: rotate(45deg);
}