mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-09-14 06:50:20 +00:00
Remove animejs (#982)
This commit is contained in:
parent
1b306b9824
commit
8fa97a173a
@ -1,11 +1,6 @@
|
|||||||
# This file is automatically generated
|
# This file is automatically generated
|
||||||
# See https://github.com/next-theme/plugins
|
# See https://github.com/next-theme/plugins
|
||||||
|
|
||||||
anime:
|
|
||||||
name: animejs
|
|
||||||
version: 3.2.1
|
|
||||||
file: lib/anime.min.js
|
|
||||||
integrity: sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=
|
|
||||||
fontawesome:
|
fontawesome:
|
||||||
name: '@fortawesome/fontawesome-free'
|
name: '@fortawesome/fontawesome-free'
|
||||||
version: 7.0.0
|
version: 7.0.0
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
hexo.extend.helper.register('js_vendors', function() {
|
hexo.extend.helper.register('js_vendors', function() {
|
||||||
const { config, theme } = this;
|
const { config, theme } = this;
|
||||||
const vendors = ['anime'];
|
const vendors = [];
|
||||||
if (theme.prism.enable && !config.prismjs.preprocess) {
|
if (theme.prism.enable && !config.prismjs.preprocess) {
|
||||||
vendors.push('prism', 'prism_autoloader');
|
vendors.push('prism', 'prism_autoloader');
|
||||||
if (config.prismjs.line_number) {
|
if (config.prismjs.line_number) {
|
||||||
|
|||||||
@ -31,17 +31,25 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
// Save the position by clicking the icon
|
// Save the position by clicking the icon
|
||||||
link.addEventListener('click', () => {
|
link.addEventListener('click', () => {
|
||||||
doSaveScroll();
|
doSaveScroll();
|
||||||
window.anime({
|
if (typeof link.animate !== 'function') {
|
||||||
targets : link,
|
link.style.top = '-30px';
|
||||||
|
setTimeout(() => {
|
||||||
|
link.style.top = '';
|
||||||
|
}, 600);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const animation = link.animate([{}, { top: '-30px' }], {
|
||||||
duration: 200,
|
duration: 200,
|
||||||
easing : 'linear',
|
easing : 'linear',
|
||||||
top : -30,
|
fill : 'forwards'
|
||||||
complete: () => {
|
|
||||||
setTimeout(() => {
|
|
||||||
link.style.top = '';
|
|
||||||
}, 400);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
animation.finished.then(() => {
|
||||||
|
link.style.top = '-30px';
|
||||||
|
animation.cancel();
|
||||||
|
setTimeout(() => {
|
||||||
|
link.style.top = '';
|
||||||
|
}, 400);
|
||||||
|
}).catch(() => {});
|
||||||
});
|
});
|
||||||
scrollToMark();
|
scrollToMark();
|
||||||
document.addEventListener('pjax:success', scrollToMark);
|
document.addEventListener('pjax:success', scrollToMark);
|
||||||
|
|||||||
@ -14,16 +14,38 @@ NexT.motion.integrator = {
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
bootstrap() {
|
bootstrap() {
|
||||||
|
if (typeof Element.prototype.animate !== 'function') {
|
||||||
|
document.body.classList.remove('use-motion');
|
||||||
|
CONFIG.motion.enable = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!CONFIG.motion.async) this.queue = [this.queue.flat()];
|
if (!CONFIG.motion.async) this.queue = [this.queue.flat()];
|
||||||
this.queue.forEach(sequence => {
|
this.queue.forEach(sequence => this.schedule(sequence));
|
||||||
const timeline = window.anime.timeline({
|
},
|
||||||
duration: CONFIG.motion?.duration ?? 200,
|
schedule(sequence) {
|
||||||
easing : 'linear'
|
let cursor = 0;
|
||||||
});
|
sequence.forEach(item => {
|
||||||
sequence.forEach(item => {
|
const duration = item.duration ?? CONFIG.motion?.duration ?? 200;
|
||||||
if (item.deltaT) timeline.add(item, item.deltaT);
|
const start = Math.max(0, cursor - (item.overlap ?? 0));
|
||||||
else timeline.add(item);
|
const end = start + duration;
|
||||||
});
|
cursor = Math.max(cursor, end);
|
||||||
|
|
||||||
|
if (item.styles) {
|
||||||
|
const targets = typeof item.targets === 'string' ? document.querySelectorAll(item.targets) : [item.targets].filter(Boolean);
|
||||||
|
targets.forEach(target => {
|
||||||
|
const animation = target.animate([{}, item.styles], {
|
||||||
|
delay : start,
|
||||||
|
duration,
|
||||||
|
easing: 'linear',
|
||||||
|
fill : 'forwards'
|
||||||
|
});
|
||||||
|
animation.finished.then(() => {
|
||||||
|
Object.assign(target.style, item.styles);
|
||||||
|
animation.cancel();
|
||||||
|
}).catch(() => {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (item.complete) setTimeout(item.complete, end);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -35,18 +57,17 @@ NexT.motion.middleWares = {
|
|||||||
function getMistLineSettings(targets) {
|
function getMistLineSettings(targets) {
|
||||||
sequence.push({
|
sequence.push({
|
||||||
targets,
|
targets,
|
||||||
scaleX : [0, 1],
|
styles : { transform: 'scaleX(1)' },
|
||||||
duration: 500,
|
duration: 500,
|
||||||
deltaT : '-=200'
|
overlap : 200
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function pushToSequence(targets, sequenceQueue = false) {
|
function pushToSequence(targets, sequenceQueue = false) {
|
||||||
sequence.push({
|
sequence.push({
|
||||||
targets,
|
targets,
|
||||||
opacity: 1,
|
styles : { opacity: 1, top: '0px' },
|
||||||
top : 0,
|
overlap: sequenceQueue ? 200 : 0
|
||||||
deltaT : sequenceQueue ? '-=200' : '-=0'
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +85,7 @@ NexT.motion.middleWares = {
|
|||||||
sequence.push({
|
sequence.push({
|
||||||
targets,
|
targets,
|
||||||
complete: () => targets.classList.add('animated', menuItemTransition),
|
complete: () => targets.classList.add('animated', menuItemTransition),
|
||||||
deltaT : '-=200'
|
overlap : 200
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -92,7 +113,7 @@ NexT.motion.middleWares = {
|
|||||||
sequence.push({
|
sequence.push({
|
||||||
targets,
|
targets,
|
||||||
complete: () => targets.classList.add('animated', animation),
|
complete: () => targets.classList.add('animated', animation),
|
||||||
deltaT : '-=100'
|
overlap : 100
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -101,7 +122,7 @@ NexT.motion.middleWares = {
|
|||||||
sequence.push({
|
sequence.push({
|
||||||
targets,
|
targets,
|
||||||
complete: () => targets.classList.add('animated', post_block),
|
complete: () => targets.classList.add('animated', post_block),
|
||||||
deltaT : '-=100'
|
overlap : 100
|
||||||
});
|
});
|
||||||
animate(coll_header, targets.querySelectorAll('.collection-header'));
|
animate(coll_header, targets.querySelectorAll('.collection-header'));
|
||||||
animate(post_header, targets.querySelectorAll('.post-header'));
|
animate(post_header, targets.querySelectorAll('.post-header'));
|
||||||
@ -123,7 +144,7 @@ NexT.motion.middleWares = {
|
|||||||
sequence.push({
|
sequence.push({
|
||||||
targets,
|
targets,
|
||||||
complete: () => targets.classList.add('animated', sidebarTransition),
|
complete: () => targets.classList.add('animated', sidebarTransition),
|
||||||
deltaT : '-=100'
|
overlap : 100
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -133,7 +154,7 @@ NexT.motion.middleWares = {
|
|||||||
footer() {
|
footer() {
|
||||||
return [{
|
return [{
|
||||||
targets: document.querySelector('.footer'),
|
targets: document.querySelector('.footer'),
|
||||||
opacity: 1
|
styles : { opacity: 1 }
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user