惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
NISL@THU
NISL@THU
E
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
K
Kaspersky official blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
S
Schneier on Security
G
GRAHAM CLULEY
The Hacker News
The Hacker News
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
T
Tor Project blog
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
爱范儿
爱范儿
P
Privacy International News Feed
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
S
Securelist
G
Google Developers Blog
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
美团技术团队
F
Fortinet All Blogs
小众软件
小众软件
Recorded Future
Recorded Future
V
Visual Studio Blog
B
Blog RSS Feed
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
Latest news
Latest news
Spread Privacy
Spread Privacy
H
Heimdal Security Blog

爱吃肉的猫

那就,再相逢 Butterfly的魔改教程:最新评论页 离歌不夜天 前端分享 - 滑动阻尼效果 Butterfly的魔改教程:右键菜单 音乐分享 - doi微醺氛围 Butterfly的魔改教程:动态相册页 近况记事 - 11 微信公众号:Ai大模型让回复更具智能化 近况记事 - 10 PWA:让你的网站变成桌面应用APP Healthy Love Butterfly的魔改教程:关于本站 近况记事 - 9 Butterfly的魔改教程:待办清单 TrollStore - 不掉签助手 近况记事 - 8 Twikoo评论回复邮件模版 过一个很特别的七夕 The Young Boy and the Sea Butterfly的魔改教程:文章订阅页 思考题目:混乱是阶梯 近况记事 - 7 Butterfly的魔改教程:即刻短文页 差旅游记 再见,不惑之年:二十又一 近况记事 - 6 Butterfly的魔改教程:自定页数跳转 堆友AI作图:3D资源设计平台,堆出你的未来 【QD-Today】自建私有自动签到服务 Long time no see Butterfly的魔改教程:聊天记录页 Butterfly的魔改教程:个性定位信息 近况记事 - 5 Butterfly的魔改教程:好物推荐页 CDN加速 二刷《想见你》 网络言论不是法外之地 近况记事 - 4 深夜训斥 近况记事 - 3 近况记事 - 2 日常打理的那些事 Butterfly的魔改教程:随机阅读一篇文章 随笔 · 封 布柒糖FM项目进展报告 清明路雨纷纷 TA - 仲夏夜的荒原 重构记录 - 4 近况记事 Butterfly的魔改教程:评论弹窗 2021款 Model Y 近两年用车总结 重构记录 - 3 百日祭 避风的港湾 Emoji表情大全 iCat-APP 开源记录 Butterfly的调整教程:文章外挂标签美化 iOS修改 - 万铲铲的致富之路 Markdown 基础教程 从你的全世界路过 小米摄像头!避!雷! VuePress 搭建教程 Hexo跳过指定文件渲染 百度贴吧每日自动签到 重构记录 - 1 GitHub Desktop提交报错 快速批量处理重命名 Git连接仓库常用命令 Ubuntu处理deb命令 掘金自动签到并挖矿 一个简洁的橙色调个人简介 我的猫以前也是流浪猫 布柒糖FM 最新指北 初学写个了油猴脚本 幽灵404页面 PC游戏 · 植物大战僵尸 语言包 · 越狱篇 砸壳多开 · 越狱篇 HuiRan Cursors 手动关闭Win10自动更新 iPhone XR 完美越狱 成功实例 三年的跌撞 关于《小橘妈妈》 魔改前置教程:添加自定义css和js文件 Hexo 博客添加RSS插件 Butterfly的魔改教程:导航栏魔改美化
Butterfly的魔改教程:loading加载动画
亦小封 · 2023-07-27 · via 爱吃肉的猫

临时写的一个loading,可能会有些bug样式,第一版先这样,后面会继续修。

正常模式

暗黑模式

  • 修改[blogRoot]/themes/butterfly/layout/includes/loading/fullpage-loading.pug页面内容。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
-#loading-box
- .loading-left-bg
- .loading-right-bg
- .spinner-box
- .configure-border-1
- .configure-core
- .configure-border-2
- .configure-core
- .loading-word= _p('loading')
+#loading-box(onclick='document.getElementById("loading-box").classList.add("loaded")')
+ #icat-splash
+ .icat-loading
+ img(src=url_for(theme.preloader.logo) data-src=url_for(theme.preloader.logo_dark))

script.
+ var htmlElement = document.querySelector('html');
+ if (htmlElement.getAttribute('data-theme') === 'dark') {
+ var imgElement = document.querySelector('.icat-loading img');
+ var dataSrc = imgElement.getAttribute('data-src');
+ imgElement.src = dataSrc;
+ }
+
const preloader = {
endLoading: () => {
- document.body.style.overflow = '';
+ document.body.style.overflow = 'auto';
document.getElementById('loading-box').classList.add("loaded")
},
initLoading: () => {
- document.body.style.overflow = '';
+ document.body.style.overflow = 'hidden';
document.getElementById('loading-box').classList.remove("loaded")
}
}
+
+ preloader.initLoading()
window.addEventListener('load',()=> { preloader.endLoading() })

if (!{theme.pjax && theme.pjax.enable}) {
document.addEventListener('pjax:send', () => { preloader.initLoading() })
document.addEventListener('pjax:complete', () => { preloader.endLoading() })
}
  • 替换[blogRoot]/themes/butterfly/source/css/_layout/loading.styl内容。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
if hexo-config('preloader')
#loading-box.loaded
#icat-splash
opacity: 0
z-index: -1000

#icat-splash
display: -webkit-box
display: -moz-box
display: -webkit-flex
display: -ms-flexbox
display: box
display: flex
justify-content: center
align-items: center
width: 100%
height: 100%
position: fixed
background: var(--icat-card-bg)
z-index: 1999
opacity: 1
-ms-filter: none
filter: none
-webkit-transition: .3s
-moz-transition: .3s
-o-transition: .3s
-ms-transition: .3s
transition: .3s

.icat-loading
width: 30%
height: auto
overflow: hidden
display: flex
justify-content: center
position: relative

@media screen and (max-width: 768px)
width: 50%

img
width: 100%
height: auto
-webkit-filter: brightness(1)
-moz-filter: brightness(1)
-o-filter: brightness(1)
-ms-filter: brightness(1)
filter: brightness(1)

&::before
content: ""
display: inline-block
width: 100%
height: 400%
background-image: linear-gradient(to bottom, #FCFCFC, #FCFCFC 25%, #E8FF00 25%, #E8FF00 50%, #34BE89 50%, #34BE89 75%, #FCFCFC 75%, #FCFCFC)
background-position: center top
position: absolute
top: 0
animation-name: loading
animation-delay: 0.5s
animation-duration: 4s
animation-iteration-count: infinite
animation-timing-function: linear

[data-theme="dark"]
background-image: linear-gradient(to bottom, #1d1e22, #1d1e22 25%, #E8FF00 25%, #E8FF00 50%, #34BE89 50%, #34BE89 75%, #1d1e22 75%, #1d1e22)

@keyframes loading
from
top: 0
to
top: -300%
  • 新增_config.butterfly.yml主题配置文件的preloader里的子配置项logologo_dark
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  ···




preloader:
enable: true
source: 1


pace_css_url:
+ logo: https://s11.ax1x.com/2023/07/28/pCxGRfg.png
+ logo_dark: https://s11.ax1x.com/2023/07/28/pCxG2tS.png


···

Heo版Avatar加载

本小节仅适用 Butterfly 4.5 以上版本

  • 修改[blogRoot]/themes/butterfly/layout/includes/loading/fullpage-loading.pug页面内容
    + 号直接删除 即是正常缩进)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
-#loading-box
- .loading-left-bg
- .loading-right-bg
- .spinner-box
- .configure-border-1
- .configure-core
- .configure-border-2
- .configure-core
- .loading-word= _p('loading')
+#loading-box(onclick='document.getElementById("loading-box").classList.add("loaded")')
+ .loading-bg
+ div.loading-img(style=`background-image:url(${theme.preloader.avatar});background-repeat: no-repeat;background-position:center;`)
+ .loading-image-dot

script.
const preloader = {
endLoading: () => {
- document.body.style.overflow = '';
+ document.body.style.overflow = 'auto';
document.getElementById('loading-box').classList.add("loaded")
},
initLoading: () => {
- document.body.style.overflow = '';
+ document.body.style.overflow = 'hidden';
document.getElementById('loading-box').classList.remove("loaded")
}
}
+
+ preloader.initLoading()
window.addEventListener('load',()=> { preloader.endLoading() })

if (!{theme.pjax && theme.pjax.enable}) {
document.addEventListener('pjax:send', () => { preloader.initLoading() })
document.addEventListener('pjax:complete', () => { preloader.endLoading() })
}
  • 修改[blogRoot]/themes/butterfly/layout/includes/loading/index.pug页面内容
    + 号直接删除 即是正常缩进)
1
2
3
4
5
6
7
if theme.preloader.source === 1
include ./fullpage-loading.pug
+else if theme.preloader.source === 2
+ include ./pace.pug
else
+ include ./fullpage-loading.pug
include ./pace.pug
  • 在自建的CSS文件[blogRoot]/source/css/icat_change.css里新增以下内容

这一步是修改 pace 加载的胶囊 💊 样式用的
可以单独新建个css文件,将下面的样式放进去,也可以不做这一步,那么在主题配置文件pace_css_url这一项就要留空

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
.pace {
-webkit-pointer-events: none;
pointer-events: none;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
z-index: 2000;
position: fixed;
margin: auto;
top: 10px;
left: 0;
right: 0;
height: 8px;
border-radius: 8px;
width: 4rem;
background: #eaecf2;
border: 1px #e3e8f7;
overflow: hidden;
}
.pace-inactive .pace-progress {
opacity: 0;
transition: 0.3s ease-in;
}
.pace .pace-progress {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
-o-box-sizing: border-box;
box-sizing: border-box;
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
max-width: 200px;
position: absolute;
z-index: 2000;
display: block;
top: 0;
right: 100%;
height: 100%;
width: 100%;
background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
animation: gradient 1.5s ease infinite;
background-size: 200%;
}
.pace.pace-inactive {
opacity: 0;
transition: 0.3s;
top: -8px;
}
@keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}


  • 替换[blogRoot]/themes/butterfly/source/css/_layout/loading.styl内容。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
if hexo-config('preloader')
.loading-bg
display: flex;
width: 100%;
height: 100%;
position: fixed;
background: var(--icat-card-bg);
z-index: 1001;
opacity: 1;
transition: .3s;

#loading-box
.loading-img
width: 100px;
height: 100px;
border-radius: 50%;
margin: auto;
border: 4px solid #f0f0f2;
animation-duration: .3s;
animation-name: loadingAction;
animation-iteration-count: infinite;
animation-direction: alternate;
background-size: cover;
.loading-image-dot
width: 30px;
height: 30px;
background: #6bdf8f;
position: absolute;
border-radius: 50%;
border: 6px solid #fff;
top: 50%;
left: 50%;
transform: translate(18px, 24px);
&.loaded
.loading-bg
opacity: 0;
z-index: -1000;

@keyframes loadingAction
0% {
opacity: 1;
}

100% {
opacity: .4;
}
  • 新增_config.butterfly.yml主题配置文件的preloader里的子配置项avatar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  ···




preloader:
enable: true
source: 3


pace_css_url: /css/icat_change.css
+ avatar: https://s11.ax1x.com/2023/07/07/pCc1TSO.jpg


···
  • source: 1满屏加载无pace胶囊。
  • source: 2pace胶囊无满屏动画。
  • source: 3两者都启用。

更新历史

  • 230728 更新:将样式整合为loading.styl,省去link引用

Butterfly的魔改教程:loading加载动画

此文章版权归 MeuiCat 所有,完整转载,请注明来源!