From 0ed4632f347a988b644b55427eb323446ebb230b Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Sun, 1 Jan 2023 20:49:42 +0800 Subject: [PATCH] Reorder the animations of post lists --- source/css/_schemes/Gemini/index.styl | 4 ++-- source/js/motion.js | 20 ++++++++++++++------ source/js/utils.js | 4 ++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/source/css/_schemes/Gemini/index.styl b/source/css/_schemes/Gemini/index.styl index c8b6f6f..748d11c 100644 --- a/source/css/_schemes/Gemini/index.styl +++ b/source/css/_schemes/Gemini/index.styl @@ -25,7 +25,7 @@ // ================================================== // Post blocks. .main-inner { - .sub-menu, .post-block, .tabs-comment, .comments, .pagination { + .sub-menu, .post-block, .tabs-comment, :not(.tab-pane) > .comments, .pagination { gemini-block(); } @@ -35,7 +35,7 @@ } } - .tabs-comment, .comments, .pagination { + .tabs-comment, :not(.tab-pane) > .comments, .pagination { gemini-block-not-first(); } } diff --git a/source/js/motion.js b/source/js/motion.js index 7ef54b0..aad22db 100644 --- a/source/js/motion.js +++ b/source/js/motion.js @@ -87,9 +87,9 @@ NexT.motion.middleWares = { const sequence = []; const { post_block, post_header, post_body, coll_header } = CONFIG.motion.transition; - function animate(animation, selector) { + function animate(animation, elements) { if (!animation) return; - document.querySelectorAll(selector).forEach(targets => { + elements.forEach(targets => { sequence.push({ targets, complete: () => targets.classList.add('animated', animation), @@ -98,10 +98,18 @@ NexT.motion.middleWares = { }); } - animate(post_block, '.post-block, .pagination, .comments'); - animate(coll_header, '.collection-header'); - animate(post_header, '.post-header'); - animate(post_body, '.post-body'); + document.querySelectorAll('.post-block').forEach(targets => { + sequence.push({ + targets, + complete: () => targets.classList.add('animated', post_block), + deltaT : '-=100' + }); + animate(coll_header, targets.querySelectorAll('.collection-header')); + animate(post_header, targets.querySelectorAll('.post-header')); + animate(post_body, targets.querySelectorAll('.post-body')); + }); + + animate(post_block, document.querySelectorAll('.pagination, .comments')); return sequence; }, diff --git a/source/js/utils.js b/source/js/utils.js index b9cf393..949cd97 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -176,11 +176,11 @@ NexT.utils = { tabContent.style.overflow = 'hidden'; tabContent.style.transition = 'height 1s'; // Comment system selection tab does not contain .active class. - const activeTab = tabContent.querySelector('.active') || tabContent.firstChild; + const activeTab = tabContent.querySelector('.active') || tabContent.firstElementChild; // Hight might be `auto`. const prevHeight = parseInt(window.getComputedStyle(activeTab).height.replace('px', ''), 10) || 0; const paddingTop = parseInt(window.getComputedStyle(activeTab).paddingTop.replace('px', ''), 10); - const marginBottom = parseInt(window.getComputedStyle(activeTab.firstChild).marginBottom.replace('px', ''), 10); + const marginBottom = parseInt(window.getComputedStyle(activeTab.firstElementChild).marginBottom.replace('px', ''), 10); tabContent.style.height = prevHeight + paddingTop + marginBottom + 'px'; // Add & Remove active class on `nav-tabs` & `tab-content`. [...nav.children].forEach(target => {