From b39ba186d90f1e198de2276ada515cda161918aa Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Sun, 28 Jun 2020 16:06:23 +0800 Subject: [PATCH] Refactor motion --- layout/_partials/header/brand.njk | 4 +- layout/_partials/widgets.njk | 7 +++ layout/_scripts/noscript.njk | 7 +-- .../css/_common/outline/header/site-meta.styl | 4 -- .../css/_common/outline/header/site-nav.styl | 8 +++ source/css/_schemes/Mist/_header.styl | 6 +- source/js/motion.js | 62 ++++++++----------- 7 files changed, 49 insertions(+), 49 deletions(-) diff --git a/layout/_partials/header/brand.njk b/layout/_partials/header/brand.njk index 65a5335..7743871 100644 --- a/layout/_partials/header/brand.njk +++ b/layout/_partials/header/brand.njk @@ -15,9 +15,9 @@ {%- endif %} - +

{{ title }}

- +
{%- if subtitle %}

{{ subtitle }}

diff --git a/layout/_partials/widgets.njk b/layout/_partials/widgets.njk index 09658d4..80aa8de 100644 --- a/layout/_partials/widgets.njk +++ b/layout/_partials/widgets.njk @@ -4,12 +4,15 @@ 0% {%- endif %} + {%- if theme.reading_progress.enable %}
{%- endif %} + {%- if theme.bookmark.enable %} {%- endif %} + {%- if theme.github_banner.enable %} {%- set github_URL = theme.github_banner.permalink %} {%- set github_title = theme.github_banner.title %} @@ -18,3 +21,7 @@ {{ next_url(github_URL, github_image, {class: 'github-corner', title: github_title, "aria-label": github_title}) }} {%- endif %} + + diff --git a/layout/_scripts/noscript.njk b/layout/_scripts/noscript.njk index 1917b00..33621ed 100644 --- a/layout/_scripts/noscript.njk +++ b/layout/_scripts/noscript.njk @@ -2,7 +2,6 @@ -
Theme NexT works best with JavaScript enabled
diff --git a/source/css/_common/outline/header/site-meta.styl b/source/css/_common/outline/header/site-meta.styl index 6614edd..3afb6e3 100644 --- a/source/css/_common/outline/header/site-meta.styl +++ b/source/css/_common/outline/header/site-meta.styl @@ -40,10 +40,6 @@ } .use-motion { - .brand { - opacity: 0; - } - .site-title, .site-subtitle, .custom-logo-image { opacity: 0; position: relative; diff --git a/source/css/_common/outline/header/site-nav.styl b/source/css/_common/outline/header/site-nav.styl index 3a8e50b..8979a4e 100644 --- a/source/css/_common/outline/header/site-nav.styl +++ b/source/css/_common/outline/header/site-nav.styl @@ -26,3 +26,11 @@ display: block; } } + +.use-motion { + .site-brand-container .toggle { + opacity: 0; + position: relative; + top: -10px; + } +} diff --git a/source/css/_schemes/Mist/_header.styl b/source/css/_schemes/Mist/_header.styl index 9795376..30a4525 100644 --- a/source/css/_schemes/Mist/_header.styl +++ b/source/css/_schemes/Mist/_header.styl @@ -27,7 +27,7 @@ } } -.logo-line-before, .logo-line-after { +.logo-line { background: var(--brand-color); display: block; height: 2px; @@ -40,12 +40,12 @@ } .use-motion { - .logo-line-before { + .logo-line:first-of-type { transform-origin: left; transform: scaleX(0); } - .logo-line-after { + .logo-line:last-of-type { transform-origin: right; transform: scaleX(0); } diff --git a/source/js/motion.js b/source/js/motion.js index ebeefcc..9873778 100644 --- a/source/js/motion.js +++ b/source/js/motion.js @@ -29,60 +29,50 @@ NexT.motion.integrator = { NexT.motion.middleWares = { logo: function(integrator) { const sequence = []; - const brand = document.querySelector('.brand'); const image = document.querySelector('.custom-logo-image'); const title = document.querySelector('.site-title'); const subtitle = document.querySelector('.site-subtitle'); - const logoLineTop = document.querySelector('.logo-line-before'); - const logoLineBottom = document.querySelector('.logo-line-after'); - - brand && sequence.push({ - e: brand, - p: {opacity: 1}, - o: {duration: 200} - }); + const toggle = document.querySelectorAll('.site-brand-container .toggle'); + const logoLine = document.querySelectorAll('.logo-line'); function getMistLineSettings(element) { Velocity.hook(element, 'scaleX', 0); - return { + sequence.push({ e: element, - p: {scaleX: 1}, + p: { + scaleX: 1 + }, o: { duration : 500, sequenceQueue: false } - }; - } - - function pushImageToSequence() { - sequence.push({ - e: image, - p: {opacity: 1, top: 0}, - o: {duration: 200} }); } - CONFIG.scheme === 'Mist' && logoLineTop && logoLineBottom - && sequence.push( - getMistLineSettings(logoLineTop), - getMistLineSettings(logoLineBottom) - ); + function pushToSequence(element) { + sequence.push({ + e: element, + p: { + opacity: 1, + top : 0 + }, + o: { + duration: 200 + } + }); + } - CONFIG.scheme === 'Muse' && image && pushImageToSequence(); + CONFIG.scheme === 'Mist' && logoLine.length && getMistLineSettings(logoLine); - title && sequence.push({ - e: title, - p: {opacity: 1, top: 0}, - o: {duration: 200} - }); + CONFIG.scheme === 'Muse' && image && pushToSequence(image); - subtitle && sequence.push({ - e: subtitle, - p: {opacity: 1, top: 0}, - o: {duration: 200} - }); + title && pushToSequence(title); - (CONFIG.scheme === 'Pisces' || CONFIG.scheme === 'Gemini') && image && pushImageToSequence(); + subtitle && pushToSequence(subtitle); + + toggle.length && pushToSequence(toggle); + + (CONFIG.scheme === 'Pisces' || CONFIG.scheme === 'Gemini') && image && pushToSequence(image); if (sequence.length > 0) { sequence[sequence.length - 1].o.complete = function() {