Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ source/lib/font-awesome/less/
source/lib/font-awesome/scss/
!source/lib/font-awesome/

!source/lib/jquery/
!source/lib/anime.min.js

!source/lib/velocity/
11 changes: 5 additions & 6 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -962,11 +962,10 @@ vendors:
# Internal path prefix. Please do not edit it.
_internal: lib

# Internal version: 3.4.1
# Internal version: 3.1.0
# Example:
# jquery: //cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js
# jquery: //cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js
jquery:
# anime: //cdn.jsdelivr.net/npm/animejs@3.1.0/lib/anime.min.js
anime:

# Internal version: 4.7.0
# Example:
Expand Down Expand Up @@ -1000,10 +999,10 @@ vendors:

# FancyBox
# Example:
# jquery: //cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js
# fancybox: //cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js
# fancybox: //cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js
# fancybox_css: //cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css
# fancybox_css: //cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css
jquery:
fancybox:
fancybox_css:

Expand Down
4 changes: 2 additions & 2 deletions layout/_macro/sidebar.swig
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
{%- endif %}

<ul class="sidebar-nav motion-element">
<li class="sidebar-nav-toc" data-target="post-toc-wrap">
<li class="sidebar-nav-toc" data-target="0">
{{ __('sidebar.toc') }}
</li>
<li class="sidebar-nav-overview" data-target="site-overview-wrap">
<li class="sidebar-nav-overview" data-target="1">
{{ __('sidebar.overview') }}
</li>
</ul>
Expand Down
14 changes: 8 additions & 6 deletions layout/_scripts/vendors.swig
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{%- set js_vendors = {} %}
{%- set js_defer_vendors = {} %}
{%- set js_vendors.jquery = 'jquery/index.js?v=3.4.1' %}
{%- set js_vendors.anime = 'anime.min.js?v=3.1.0' %}

{# Velocity must be loaded before jQuery #}
{%- if theme.motion.enable %}
{%- set js_vendors.velocity = 'velocity/velocity.min.js?v=1.2.1' %}
{%- set js_vendors.velocity_ui = 'velocity/velocity.ui.min.js?v=1.2.1' %}
{%- endif %}

{%- if theme.pjax %}
{%- set js_vendors.pjax = 'pjax/pjax.min.js?v=0.2.8' %}
{%- endif %}

{%- if theme.fancybox %}
{%- set js_vendors.jquery = '//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js' %}
{%- set js_vendors.fancybox = '//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js' %}
{%- endif %}

Expand All @@ -22,11 +29,6 @@
{%- set js_vendors.pangu = '//cdn.jsdelivr.net/npm/pangu@4/dist/browser/pangu.min.js' %}
{%- endif %}

{%- if theme.motion.enable %}
{%- set js_vendors.velocity = 'velocity/velocity.min.js?v=1.2.1' %}
{%- set js_vendors.velocity_ui = 'velocity/velocity.ui.min.js?v=1.2.1' %}
{%- endif %}

{%- if theme.three.enable and not theme.three.delay %}
{%- if theme.three.three_waves %}
{%- set js_defer_vendors.three = 'three/three.min.js' %}
Expand Down
4 changes: 2 additions & 2 deletions scripts/filters/minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ hexo.extend.filter.register('after_generate', () => {
});
}

if (theme.vendors.jquery) {
hexo.route.remove('lib/jquery/index.js');
if (theme.vendors.anime) {
hexo.route.remove('lib/anime.min.js');
}

if (!theme.algolia_search.enable) {
Expand Down
4 changes: 4 additions & 0 deletions source/css/_common/components/header/site-nav.styl
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@
margin: 0 -10px;
padding: 0 10px;
}

&.site-nav-on {
display: block;
}
}
4 changes: 0 additions & 4 deletions source/css/_schemes/Pisces/_menu.styl
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@

+tablet() {
display: none;

&.site-nav-on {
display: block;
}
}
}

Expand Down
23 changes: 15 additions & 8 deletions source/js/bookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ window.addEventListener('DOMContentLoaded', () => {
// If the page opens with a specific hash, just jump out
if (!isNaN(top) && location.hash === '') {
// Auto scroll to the position
$(document.documentElement).animate({
window.anime({
targets : document.documentElement,
duration : 200,
easing : 'linear',
scrollTop: top
}, 'fast');
});
}
};
// Register everything
Expand All @@ -36,12 +39,16 @@ window.addEventListener('DOMContentLoaded', () => {
link.addEventListener('click', event => {
event.preventDefault();
doSaveScroll();
$(link).animate({
top: -30
}, 'fast', () => {
setTimeout(() => {
link.style.top = '';
}, 400);
window.anime({
targets : link,
duration: 200,
easing : 'linear',
top : -30,
complete: () => {
setTimeout(() => {
link.style.top = '';
}, 400);
}
});
});
scrollToMark();
Expand Down
16 changes: 8 additions & 8 deletions source/js/motion.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global NexT, CONFIG */
/* global NexT, CONFIG, Velocity */

NexT.motion = {};

Expand Down Expand Up @@ -85,7 +85,7 @@ NexT.motion.middleWares = {
sequence[sequence.length - 1].o.complete = function() {
integrator.next();
};
$.Velocity.RunSequence(sequence);
Velocity.RunSequence(sequence);
} else {
integrator.next();
}
Expand All @@ -97,7 +97,7 @@ NexT.motion.middleWares = {

menu: function(integrator) {

$.Velocity(document.querySelectorAll('.menu-item'), 'transition.slideDownIn', {
Velocity(document.querySelectorAll('.menu-item'), 'transition.slideDownIn', {
display : null,
duration: 200,
complete: function() {
Expand Down Expand Up @@ -132,16 +132,16 @@ NexT.motion.middleWares = {
};

if (CONFIG.motion.transition.post_block) {
$.Velocity(postBlock, 'transition.' + postBlockTransition, postMotionOptions);
Velocity(postBlock, 'transition.' + postBlockTransition, postMotionOptions);
}
if (CONFIG.motion.transition.post_header) {
$.Velocity(postHeader, 'transition.' + postHeaderTransition, postMotionOptions);
Velocity(postHeader, 'transition.' + postHeaderTransition, postMotionOptions);
}
if (CONFIG.motion.transition.post_body) {
$.Velocity(postBody, 'transition.' + postBodyTransition, postMotionOptions);
Velocity(postBody, 'transition.' + postBodyTransition, postMotionOptions);
}
if (CONFIG.motion.transition.coll_header) {
$.Velocity(collHeader, 'transition.' + collHeaderTransition, postMotionOptions);
Velocity(collHeader, 'transition.' + collHeaderTransition, postMotionOptions);
}
}
if (NexT.utils.isPisces() || NexT.utils.isGemini()) {
Expand All @@ -155,7 +155,7 @@ NexT.motion.middleWares = {
var sidebarAffixTransition = CONFIG.motion.transition.sidebar;
// Only for Pisces | Gemini.
if (CONFIG.motion.transition.sidebar && (NexT.utils.isPisces() || NexT.utils.isGemini())) {
$.Velocity(sidebarAffix, 'transition.' + sidebarAffixTransition, {
Velocity(sidebarAffix, 'transition.' + sidebarAffixTransition, {
display : null,
duration: 200,
complete: function() {
Expand Down
62 changes: 40 additions & 22 deletions source/js/next-boot.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global NexT, CONFIG */
/* global NexT, CONFIG, Velocity */

NexT.boot = {};

Expand All @@ -9,39 +9,57 @@ NexT.boot.registerEvents = function() {

// Mobile top menu bar.
document.querySelector('.site-nav-toggle button').addEventListener('click', () => {
var $siteNav = $('.site-nav');
var siteNav = document.querySelector('.site-nav');
var ON_CLASS_NAME = 'site-nav-on';
var isSiteNavOn = $siteNav.hasClass(ON_CLASS_NAME);
var animateAction = isSiteNavOn ? 'slideUp' : 'slideDown';
var animateCallback = isSiteNavOn ? 'removeClass' : 'addClass';
var animateAction = siteNav.classList.contains(ON_CLASS_NAME) ? 'slideUp' : 'slideDown';

$siteNav.stop()[animateAction]('fast', () => {
$siteNav[animateCallback](ON_CLASS_NAME);
});
if (typeof Velocity === 'function') {
Velocity(siteNav, animateAction, {
duration: 200,
complete: function() {
siteNav.classList.toggle(ON_CLASS_NAME);
}
});
} else {
siteNav.classList.toggle(ON_CLASS_NAME);
}
});

var TAB_ANIMATE_DURATION = 200;
document.querySelectorAll('.sidebar-nav li').forEach(li => {
li.addEventListener('click', event => {
var item = $(event.currentTarget);
var item = event.currentTarget;
var activeTabClassName = 'sidebar-nav-active';
var activePanelClassName = 'sidebar-panel-active';
if (item.hasClass(activeTabClassName)) return;
if (item.classList.contains(activeTabClassName)) return;

var target = $('.' + item.data('target'));
var currentTarget = target.siblings('.sidebar-panel');
currentTarget.animate({ opacity: 0 }, TAB_ANIMATE_DURATION, () => {
// Prevent adding TOC to Overview if Overview was selected when close & open sidebar.
currentTarget.removeClass(activePanelClassName);
target
.stop()
.css({ opacity: 0 })
.addClass(activePanelClassName)
.animate({ opacity: 1 }, TAB_ANIMATE_DURATION);
var targets = document.querySelectorAll('.sidebar-panel');
var index = item.getAttribute('data-target');
var target = targets[index];
var currentTarget = targets[1 - index];
window.anime({
targets : currentTarget,
duration: TAB_ANIMATE_DURATION,
easing : 'linear',
opacity : 0,
complete: () => {
// Prevent adding TOC to Overview if Overview was selected when close & open sidebar.
currentTarget.classList.remove(activePanelClassName);
target.css.opacity = 0;
target.classList.add(activePanelClassName);
window.anime({
targets : target,
duration: TAB_ANIMATE_DURATION,
easing : 'linear',
opacity : 1
});
}
});

item.siblings().removeClass(activeTabClassName);
item.addClass(activeTabClassName);
[...item.parentNode.children].forEach(element => {
element.classList.remove(activeTabClassName);
});
item.classList.add(activeTabClassName);
});
});

Expand Down
24 changes: 16 additions & 8 deletions source/js/schemes/muse.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global NexT, CONFIG */
/* global NexT, CONFIG, Velocity */

window.addEventListener('DOMContentLoaded', () => {

Expand Down Expand Up @@ -132,35 +132,43 @@ window.addEventListener('DOMContentLoaded', () => {
showSidebar: function() {
this.isSidebarVisible = true;
this.sidebarEl.classList.add('sidebar-active');
if (typeof $.Velocity === 'function') {
$.Velocity(document.querySelectorAll('.sidebar .motion-element:not(.site-state)'), isRight ? 'transition.slideRightIn' : 'transition.slideLeftIn', {
if (typeof Velocity === 'function') {
Velocity(document.querySelectorAll('.sidebar .motion-element:not(.site-state)'), isRight ? 'transition.slideRightIn' : 'transition.slideLeftIn', {
stagger: 50,
drag : true
});
$.Velocity(document.querySelector('.site-state'), isRight ? 'transition.slideRightIn' : 'transition.slideLeftIn', {
Velocity(document.querySelector('.site-state'), isRight ? 'transition.slideRightIn' : 'transition.slideLeftIn', {
stagger: 50,
drag : true,
display: 'flex'
});
}

sidebarToggleLines.close();
NexT.utils.isDesktop() && $('body').stop().animate(isRight ? {
NexT.utils.isDesktop() && window.anime(Object.assign({
targets : document.body,
duration: SIDEBAR_DISPLAY_DURATION,
easing : 'linear'
}, isRight ? {
'padding-right': SIDEBAR_WIDTH
} : {
'padding-left': SIDEBAR_WIDTH
}, SIDEBAR_DISPLAY_DURATION);
}));
},
hideSidebar: function() {
this.isSidebarVisible = false;
this.sidebarEl.classList.remove('sidebar-active');

sidebarToggleLines.init();
NexT.utils.isDesktop() && $('body').stop().animate(isRight ? {
NexT.utils.isDesktop() && window.anime(Object.assign({
targets : document.body,
duration: SIDEBAR_DISPLAY_DURATION,
easing : 'linear'
}, isRight ? {
'padding-right': 0
} : {
'padding-left': 0
}, SIDEBAR_DISPLAY_DURATION);
}));
}
};
sidebarToggleMotion.init();
Expand Down
Loading