summaryrefslogtreecommitdiff
path: root/layouts/_partials/scripts
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-08-29 15:21:15 +0800
committerEltrac <hi@guhub.cn>2025-08-29 15:21:15 +0800
commit3a16525c27517cd046b383f5fd92d07be6b6d798 (patch)
tree0d2a8a6448dee98c1d941d9200b2df1c55ce9600 /layouts/_partials/scripts
parent282d57b388cb5bdd67ba34bb1789fa0629d69b78 (diff)
feat: comment toggle animation
Diffstat (limited to 'layouts/_partials/scripts')
-rw-r--r--layouts/_partials/scripts/action-menu-js.html28
1 files changed, 21 insertions, 7 deletions
diff --git a/layouts/_partials/scripts/action-menu-js.html b/layouts/_partials/scripts/action-menu-js.html
index e2db17e7..a0d9391d 100644
--- a/layouts/_partials/scripts/action-menu-js.html
+++ b/layouts/_partials/scripts/action-menu-js.html
@@ -28,13 +28,27 @@ function initializeComments() {
const commentsToggle = document.getElementById('comments-toggle');
const commentsSection = document.getElementById('comments-section');
- if (commentsToggle && commentsSection) {
- commentsToggle.addEventListener('click', function() {
- const isHidden = commentsSection.style.display === 'none';
- commentsSection.style.display = isHidden ? 'block' : 'none';
- this.style.background = isHidden ? 'rgba(0, 0, 0, 0.1)' : 'transparent';
- });
- }
+ if (!commentsToggle || !commentsSection) return;
+
+ // click on toggle
+ commentsToggle.addEventListener('click', function() {
+ const isHidden = commentsSection.classList.contains('hidden');
+ const entranceAnimation = 'animate-slide-in-down';
+ const exitAnimation = 'animate-slide-out-up';
+
+ if (isHidden) {
+ // swtich on
+ commentsSection.classList.remove('hidden', exitAnimation);
+ commentsSection.classList.add(entranceAnimation);
+ } else {
+ // switch off
+ commentsSection.classList.remove(entranceAnimation);
+ commentsSection.classList.add(exitAnimation);
+ setTimeout(() => {
+ commentsSection.classList.add('hidden');
+ }, 200);
+ }
+ });
}
/**