mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-20 19:02:33 +00:00
Optimize sidebar panel animation
This commit is contained in:
parent
817ef092ac
commit
d19109a7b4
@ -48,12 +48,12 @@ NexT.boot.registerEvents = function() {
|
|||||||
element.addEventListener('click', () => {
|
element.addEventListener('click', () => {
|
||||||
if (element.matches('.sidebar-toc-active .sidebar-nav-toc, .sidebar-overview-active .sidebar-nav-overview')) return;
|
if (element.matches('.sidebar-toc-active .sidebar-nav-toc, .sidebar-overview-active .sidebar-nav-overview')) return;
|
||||||
const sidebar = document.querySelector('.sidebar-inner');
|
const sidebar = document.querySelector('.sidebar-inner');
|
||||||
const panel = document.querySelectorAll('.sidebar-panel');
|
const panel = document.querySelector('.sidebar-panel-container');
|
||||||
const activeClassName = ['sidebar-toc-active', 'sidebar-overview-active'];
|
const activeClassName = ['sidebar-toc-active', 'sidebar-overview-active'];
|
||||||
|
|
||||||
window.anime({
|
window.anime({
|
||||||
duration,
|
duration,
|
||||||
targets : panel[1 - index],
|
targets : panel,
|
||||||
easing : 'linear',
|
easing : 'linear',
|
||||||
opacity : 0,
|
opacity : 0,
|
||||||
translateY: [0, -20],
|
translateY: [0, -20],
|
||||||
@ -62,7 +62,7 @@ NexT.boot.registerEvents = function() {
|
|||||||
sidebar.classList.replace(activeClassName[1 - index], activeClassName[index]);
|
sidebar.classList.replace(activeClassName[1 - index], activeClassName[index]);
|
||||||
window.anime({
|
window.anime({
|
||||||
duration,
|
duration,
|
||||||
targets : panel[index],
|
targets : panel,
|
||||||
easing : 'linear',
|
easing : 'linear',
|
||||||
opacity : [0, 1],
|
opacity : [0, 1],
|
||||||
translateY: [-20, 0]
|
translateY: [-20, 0]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user