testing: adding smooth animation for comment hding

This commit is contained in:
2026-05-27 15:51:05 +02:00
parent b575a07921
commit c4c311c541
2 changed files with 33 additions and 23 deletions

View File

@@ -1694,7 +1694,7 @@ body.sidebar-right-hidden .global-sidebar-right {
---------------------------------------------------------- */ ---------------------------------------------------------- */
body.layout-modern .item-layout-container { body.layout-modern .item-layout-container {
display: grid; display: grid;
grid-template-columns: 400px minmax(0, 1fr) 300px; grid-template-columns: min(400px, 30vw) minmax(0, 1fr) 300px;
grid-template-rows: auto; grid-template-rows: auto;
flex: 1; flex: 1;
height: calc(100vh - var(--navbar-h, 50px)); height: calc(100vh - var(--navbar-h, 50px));
@@ -1705,7 +1705,7 @@ body.sidebar-right-hidden .global-sidebar-right {
/* Collapsed right sidebar — grid track shrinks to 0 */ /* Collapsed right sidebar — grid track shrinks to 0 */
body.layout-modern.sidebar-right-hidden .item-layout-container { body.layout-modern.sidebar-right-hidden .item-layout-container {
grid-template-columns: 400px minmax(0, 1fr) 0px; grid-template-columns: min(400px, 30vw) minmax(0, 1fr) 0px;
} }
body.layout-modern .item-sidebar-left { body.layout-modern .item-sidebar-left {
@@ -1776,6 +1776,7 @@ body.sidebar-right-hidden .global-sidebar-right {
grid-template-columns: 1fr; grid-template-columns: 1fr;
} }
/* By the time sidebar-hidden is added (post-slide), content is already off-screen */
body.layout-modern .item-layout-container.sidebar-hidden .item-sidebar-left { body.layout-modern .item-layout-container.sidebar-hidden .item-sidebar-left {
display: none; display: none;
} }
@@ -1803,15 +1804,6 @@ body.sidebar-right-hidden .global-sidebar-right {
/* Removed local sidebar and toggle overrides — now using universal rules */ /* Removed local sidebar and toggle overrides — now using universal rules */
/* Collapse right sidebar on narrower screens in modern view */
@media (max-width: 1400px) {
body.layout-modern .item-layout-container {
grid-template-columns: 400px minmax(0, 1fr);
}
/* Uses universal fixed slide-out logic; no need for display: none at this breakpoint */
}
/* ---------------------------------------------------------- /* ----------------------------------------------------------
LAYOUT: LEGACY — 2-column, natural page scroll LAYOUT: LEGACY — 2-column, natural page scroll
Right sidebar is fixed to viewport. Right sidebar is fixed to viewport.
@@ -2219,6 +2211,7 @@ body.sidebar-right-hidden .global-sidebar-right {
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
} }
/* Modern: comments fill all remaining left-sidebar space; list scrolls internally */ /* Modern: comments fill all remaining left-sidebar space; list scrolls internally */
@@ -2249,11 +2242,25 @@ body.layout-modern .item-sidebar-left .tag-controls {
flex-shrink: 0; flex-shrink: 0;
} }
#comments-container.faded-out { /* Modern layout: slide left inside the clipped sidebar column */
.item-sidebar-left #comments-container.faded-out,
.item-sidebar-left .sidebar-tags-container.faded-out,
.item-sidebar-left .tag-controls.faded-out {
transform: translateX(-110%);
pointer-events: none;
}
/* Legacy layout: simple opacity fade (overflow:visible means translateX hangs visible) */
body.layout-legacy #comments-container.faded-out {
opacity: 0; opacity: 0;
pointer-events: none; pointer-events: none;
} }
.item-sidebar-left .sidebar-tags-container,
.item-sidebar-left .tag-controls {
transition: transform 0.3s ease-in-out;
}
.comments-controls { .comments-controls {
display: flex; display: flex;

View File

@@ -3331,28 +3331,31 @@ class CommentSystem {
if (!this.container) return; if (!this.container) return;
const layout = this.container.closest('.item-layout-container'); const layout = this.container.closest('.item-layout-container');
const sidebar = this.container.closest('.item-sidebar-left');
const siblings = sidebar ? [
...sidebar.querySelectorAll('.sidebar-tags-container, .tag-controls')
] : [];
// Check if currently hidden (or fading out) // Check if currently hidden (or slid out)
const isHidden = this.container.classList.contains('faded-out') || this.container.style.display === 'none'; const isHidden = this.container.classList.contains('faded-out') || this.container.style.display === 'none';
if (isHidden) { if (isHidden) {
// SHOW // SHOW: expand grid first, then slide content in
this.container.style.display = 'block';
if (layout) layout.classList.remove('sidebar-hidden'); if (layout) layout.classList.remove('sidebar-hidden');
this.container.style.display = '';
localStorage.setItem('comments_hidden', 'false'); localStorage.setItem('comments_hidden', 'false');
// Force reflow to enable transition void this.container.offsetWidth; // force reflow so transition fires
void this.container.offsetWidth;
this.container.classList.remove('faded-out'); this.container.classList.remove('faded-out');
siblings.forEach(el => el.classList.remove('faded-out'));
} else { } else {
// HIDE // HIDE: slide content out first, then collapse grid
localStorage.setItem('comments_hidden', 'true'); localStorage.setItem('comments_hidden', 'true');
this.container.classList.add('faded-out'); this.container.classList.add('faded-out');
if (layout) layout.classList.add('sidebar-hidden'); siblings.forEach(el => el.classList.add('faded-out'));
// Wait for transition, then set display none
setTimeout(() => { setTimeout(() => {
if (this.container.classList.contains('faded-out')) { if (!this.container.classList.contains('faded-out')) return;
this.container.style.display = 'none'; this.container.style.display = 'none';
} if (layout) layout.classList.add('sidebar-hidden');
}, 300); }, 300);
} }
} }