mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-06-24 13:01:13 +00:00
Add fallback if NexT.boot.motion is failed (#953)
Co-authored-by: Mimi <1119186082@qq.com>
This commit is contained in:
parent
8aa84d79f9
commit
1746ed135c
@ -3,7 +3,7 @@
|
||||
NexT.boot = {};
|
||||
|
||||
NexT.boot.registerEvents = function() {
|
||||
|
||||
try {
|
||||
NexT.utils.registerScrollPercent();
|
||||
NexT.utils.registerCanIUseTag();
|
||||
NexT.utils.updateFooterPosition();
|
||||
@ -34,14 +34,15 @@ NexT.boot.registerEvents = function() {
|
||||
window.addEventListener('tabs:click', e => {
|
||||
NexT.utils.registerCodeblock(e.target);
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Something went wrong while NexT registering events', error);
|
||||
}
|
||||
};
|
||||
|
||||
NexT.boot.refresh = function() {
|
||||
|
||||
/**
|
||||
* Register JS handlers by condition option.
|
||||
* Need to add config option in Front-End at 'scripts/helpers/next-config.js' file.
|
||||
*/
|
||||
try {
|
||||
// Register JS handlers by condition option.
|
||||
// Need to add config option in Front-End at 'scripts/helpers/next-config.js' file.
|
||||
CONFIG.prism && window.Prism.highlightAll();
|
||||
CONFIG.mediumzoom && window.mediumZoom('.post-body :not(a) > img, .post-body > img', {
|
||||
background: 'var(--content-bg-color)'
|
||||
@ -69,17 +70,26 @@ NexT.boot.refresh = function() {
|
||||
NexT.utils.registerSidebarTOC();
|
||||
NexT.utils.registerPostReward();
|
||||
NexT.utils.registerVideoIframe();
|
||||
} catch (error) {
|
||||
console.warn('Something went wrong during NexT refresh', error);
|
||||
}
|
||||
};
|
||||
|
||||
NexT.boot.motion = function() {
|
||||
// Define Motion Sequence & Bootstrap Motion.
|
||||
if (CONFIG.motion.enable) {
|
||||
try {
|
||||
NexT.motion.integrator
|
||||
.add(NexT.motion.middleWares.header)
|
||||
.add(NexT.motion.middleWares.sidebar)
|
||||
.add(NexT.motion.middleWares.postList)
|
||||
.add(NexT.motion.middleWares.footer)
|
||||
.bootstrap();
|
||||
} catch (error) {
|
||||
console.warn('NexT Motion Error, fallback to static mode', error);
|
||||
document.body.classList.remove('use-motion');
|
||||
CONFIG.motion.enable = false;
|
||||
}
|
||||
}
|
||||
NexT.utils.updateSidebarPosition();
|
||||
};
|
||||
|
||||
@ -34,6 +34,7 @@ document.addEventListener('pjax:success', () => {
|
||||
NexT.boot.refresh();
|
||||
// Define Motion Sequence & Bootstrap Motion.
|
||||
if (CONFIG.motion.enable) {
|
||||
try {
|
||||
NexT.motion.integrator
|
||||
.init()
|
||||
.add(NexT.motion.middleWares.subMenu)
|
||||
@ -41,6 +42,11 @@ document.addEventListener('pjax:success', () => {
|
||||
.add(NexT.motion.middleWares.sidebar)
|
||||
.add(NexT.motion.middleWares.postList)
|
||||
.bootstrap();
|
||||
} catch (error) {
|
||||
console.warn('NexT Motion Error, fallback to static mode', error);
|
||||
document.body.classList.remove('use-motion');
|
||||
CONFIG.motion.enable = false;
|
||||
}
|
||||
}
|
||||
if (CONFIG.sidebar.display !== 'remove') {
|
||||
const hasTOC = document.querySelector('.post-toc:not(.placeholder-toc)');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user