2022-05-21 17:47:26 +08:00
|
|
|
/* global NexT, CONFIG */
|
|
|
|
|
|
|
|
NexT.motion = {};
|
|
|
|
|
|
|
|
NexT.motion.integrator = {
|
|
|
|
queue: [],
|
|
|
|
init : function() {
|
|
|
|
this.queue = [];
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
add: function(fn) {
|
|
|
|
const sequence = fn();
|
2022-07-13 21:25:15 +08:00
|
|
|
if (NexT.CONFIG.motion.async) this.queue.push(sequence);
|
2022-05-21 17:47:26 +08:00
|
|
|
else this.queue = this.queue.concat(sequence);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
bootstrap: function() {
|
2022-07-13 21:25:15 +08:00
|
|
|
if (!NexT.CONFIG.motion.async) this.queue = [this.queue];
|
2022-05-21 17:47:26 +08:00
|
|
|
this.queue.forEach(sequence => {
|
|
|
|
const timeline = window.anime.timeline({
|
|
|
|
duration: 200,
|
|
|
|
easing : 'linear'
|
|
|
|
});
|
|
|
|
sequence.forEach(item => {
|
|
|
|
if (item.deltaT) timeline.add(item, item.deltaT);
|
|
|
|
else timeline.add(item);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
NexT.motion.middleWares = {
|
|
|
|
header: function() {
|
|
|
|
const sequence = [];
|
|
|
|
|
|
|
|
function getMistLineSettings(targets) {
|
|
|
|
sequence.push({
|
|
|
|
targets,
|
|
|
|
scaleX : [0, 1],
|
|
|
|
duration: 500,
|
|
|
|
deltaT : '-=200'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function pushToSequence(targets, sequenceQueue = false) {
|
|
|
|
sequence.push({
|
|
|
|
targets,
|
|
|
|
opacity: 1,
|
|
|
|
top : 0,
|
|
|
|
deltaT : sequenceQueue ? '-=200' : '-=0'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
pushToSequence('header.header');
|
2022-07-13 21:25:15 +08:00
|
|
|
NexT.CONFIG.scheme === 'Mist' && getMistLineSettings('.logo-line');
|
|
|
|
NexT.CONFIG.scheme === 'Muse' && pushToSequence('.custom-logo-image');
|
2022-05-21 17:47:26 +08:00
|
|
|
pushToSequence('.site-title');
|
|
|
|
pushToSequence('.site-brand-container .toggle', true);
|
|
|
|
pushToSequence('.site-subtitle');
|
2022-07-13 21:25:15 +08:00
|
|
|
(NexT.CONFIG.scheme === 'Pisces' || NexT.CONFIG.scheme === 'Gemini') && pushToSequence('.custom-logo-image');
|
2022-05-21 17:47:26 +08:00
|
|
|
|
|
|
|
document.querySelectorAll('.menu-item').forEach(targets => {
|
|
|
|
sequence.push({
|
|
|
|
targets,
|
|
|
|
complete: () => targets.classList.add('animated', 'fadeInDown'),
|
|
|
|
deltaT : '-=200'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return sequence;
|
|
|
|
},
|
|
|
|
|
|
|
|
subMenu: function() {
|
|
|
|
const subMenuItem = document.querySelectorAll('.sub-menu .menu-item');
|
|
|
|
if (subMenuItem.length > 0) {
|
|
|
|
subMenuItem.forEach(element => {
|
|
|
|
element.classList.add('animated');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return [];
|
|
|
|
},
|
|
|
|
|
|
|
|
postList: function() {
|
|
|
|
const sequence = [];
|
2022-07-13 21:25:15 +08:00
|
|
|
const { postblock, postheader, postbody, collheader } = NexT.CONFIG.motion.transition;
|
2022-05-21 17:47:26 +08:00
|
|
|
|
|
|
|
function animate(animation, selector) {
|
|
|
|
if (!animation) return;
|
|
|
|
document.querySelectorAll(selector).forEach(targets => {
|
|
|
|
sequence.push({
|
|
|
|
targets,
|
|
|
|
complete: () => targets.classList.add('animated', animation),
|
|
|
|
deltaT : '-=100'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-08-05 15:18:52 +08:00
|
|
|
animate(postblock, '.post-block,.flinks-block, .pagination, .post-comments');
|
2022-06-18 16:09:08 +08:00
|
|
|
animate(collheader, '.collection-header');
|
|
|
|
animate(postheader, '.post-header');
|
|
|
|
animate(postbody, '.post-body');
|
2022-05-21 17:47:26 +08:00
|
|
|
|
|
|
|
return sequence;
|
|
|
|
},
|
|
|
|
|
|
|
|
sidebar: function() {
|
|
|
|
const sidebar = document.querySelector('.sidebar');
|
2022-07-13 21:25:15 +08:00
|
|
|
const sidebarTransition = NexT.CONFIG.motion.transition.sidebar;
|
2022-05-21 17:47:26 +08:00
|
|
|
// Only for Pisces | Gemini.
|
2022-07-13 21:25:15 +08:00
|
|
|
if (sidebarTransition && (NexT.CONFIG.scheme === 'Pisces' || NexT.CONFIG.scheme === 'Gemini')) {
|
2022-05-21 17:47:26 +08:00
|
|
|
return [{
|
|
|
|
targets : sidebar,
|
|
|
|
complete: () => sidebar.classList.add('animated', sidebarTransition)
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
return [];
|
|
|
|
},
|
|
|
|
|
|
|
|
footer: function() {
|
|
|
|
return [{
|
|
|
|
targets: document.querySelector('.footer'),
|
|
|
|
opacity: 1
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
};
|