Skip to content

Commit

Permalink
Reorder the animations of post lists
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Jan 1, 2023
1 parent e9cb704 commit 0ed4632
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions source/css/_schemes/Gemini/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -35,7 +35,7 @@
}
}

.tabs-comment, .comments, .pagination {
.tabs-comment, :not(.tab-pane) > .comments, .pagination {
gemini-block-not-first();
}
}
Expand Down
20 changes: 14 additions & 6 deletions source/js/motion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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;
},
Expand Down
4 changes: 2 additions & 2 deletions source/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 0ed4632

Please sign in to comment.