From 705201bde3fff01bc95ea07514c2b1dfb3f0c74e Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Wed, 23 Nov 2022 11:57:21 +0800 Subject: [PATCH] Add motion.transition.menu_item * See: https://github.com/next-theme/hexo-theme-next/issues/412 --- _config.yml | 1 + source/css/_common/outline/header/menu.styl | 6 ++++-- source/js/motion.js | 15 +++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/_config.yml b/_config.yml index 6219b59..1bd01d3 100644 --- a/_config.yml +++ b/_config.yml @@ -619,6 +619,7 @@ motion: async: false transition: # All available transition variants: https://theme-next.js.org/animate/ + menu_item: fadeInDown post_block: fadeIn post_header: fadeInDown post_body: fadeInDown diff --git a/source/css/_common/outline/header/menu.styl b/source/css/_common/outline/header/menu.styl index d5a6e0c..40ba2a6 100644 --- a/source/css/_common/outline/header/menu.styl +++ b/source/css/_common/outline/header/menu.styl @@ -51,6 +51,8 @@ } } -.use-motion .menu-item { - visibility: hidden; +if (hexo-config('motion.transition.menu_item')) { + .use-motion .menu-item { + visibility: hidden; + } } diff --git a/source/js/motion.js b/source/js/motion.js index 3192ec5..0bc8900 100644 --- a/source/js/motion.js +++ b/source/js/motion.js @@ -59,13 +59,16 @@ NexT.motion.middleWares = { pushToSequence('.site-subtitle'); (CONFIG.scheme === 'Pisces' || CONFIG.scheme === 'Gemini') && pushToSequence('.custom-logo-image'); - document.querySelectorAll('.menu-item').forEach(targets => { - sequence.push({ - targets, - complete: () => targets.classList.add('animated', 'fadeInDown'), - deltaT : '-=200' + const menuItemTransition = CONFIG.motion.transition.menu_item; + if (menuItemTransition) { + document.querySelectorAll('.menu-item').forEach(targets => { + sequence.push({ + targets, + complete: () => targets.classList.add('animated', menuItemTransition), + deltaT : '-=200' + }); }); - }); + } return sequence; },