hexo-theme-shokax 0.2.0-rc3 → 0.2.0-rc5
Sign up to get free protection for your applications and to get access to all the features.
- package/_config.yml +2 -0
- package/package.json +1 -1
- package/scripts/generaters/script.js +5 -1
- package/source/css/_common/components/post/expand.styl +0 -9
- package/source/css/_common/outline/header/image.styl +3 -1
- package/source/css/_common/outline/header/waves.styl +3 -0
- package/source/css/app.styl +2 -0
- package/source/css/optimize.styl +6 -0
- package/source/js/_app/components.js +0 -129
- package/source/js/_app/fireworks.js +129 -0
package/_config.yml
CHANGED
@@ -28,6 +28,8 @@ experiments:
|
|
28
28
|
debug: false # 使用debug模式启动
|
29
29
|
disableThemeComment: false # 禁用主题评论系统(一般用于关闭评论或让插件接管评论系统)
|
30
30
|
usingRelative: false # _image.yml 使用相对路径
|
31
|
+
optimizeLongPosts: false # 优化长文章,这能让长文章的FPS提升70%-150%并解决假死问题,但存在一些副作用
|
32
|
+
# 具体见https://docs.kaitaku.xyz/guide/theme.html#%E9%95%BF%E6%96%87%E7%AB%A0%E4%BC%98%E5%8C%96
|
31
33
|
|
32
34
|
# 优化性能区
|
33
35
|
performance:
|
package/package.json
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
/* global hexo */
|
2
2
|
const fs = require('hexo-fs')
|
3
|
-
// const url = require('url')
|
4
3
|
|
5
4
|
hexo.extend.generator.register('script', function (locals) {
|
6
5
|
const log = hexo.log || console.log
|
@@ -77,6 +76,11 @@ hexo.extend.generator.register('script', function (locals) {
|
|
77
76
|
}
|
78
77
|
}
|
79
78
|
if (theme.fireworks && theme.fireworks.enable) {
|
79
|
+
if (fs.existsSync('themes/shokaX/source/js/_app/fireworks.js')) {
|
80
|
+
text += fs.readFileSync('themes/shokaX/source/js/_app/fireworks.js').toString()
|
81
|
+
} else {
|
82
|
+
text += fs.readFileSync('node_modules/hexo-theme-shokax/source/js/_app/fireworks.js').toString()
|
83
|
+
}
|
80
84
|
siteConfig.fireworks = theme.fireworks.color || ['rgba(255,182,185,.9)', 'rgba(250,227,217,.9)', 'rgba(187,222,214,.9)', 'rgba(138,198,209,.9)']
|
81
85
|
}
|
82
86
|
|
@@ -13,21 +13,12 @@
|
|
13
13
|
img,
|
14
14
|
.tabs,
|
15
15
|
.links {
|
16
|
-
content-visibility: auto;
|
17
|
-
contain-intrinsic-size: 979px 1.1em;
|
18
16
|
&:last-child {
|
19
17
|
margin-bottom: 0;
|
20
18
|
}
|
21
19
|
}
|
22
20
|
|
23
|
-
span {
|
24
|
-
content-visibility: auto;
|
25
|
-
contain-intrinsic-size: 979px 1.1em;
|
26
|
-
}
|
27
|
-
|
28
21
|
ul, dd, ol {
|
29
|
-
content-visibility: auto;
|
30
|
-
contain-intrinsic-size: 979px 3.5em;
|
31
22
|
ul, ol {
|
32
23
|
margin-top: 0;
|
33
24
|
}
|
package/source/css/app.styl
CHANGED
@@ -1,132 +1,3 @@
|
|
1
|
-
const canvasEl = document.createElement('canvas');
|
2
|
-
canvasEl.style.cssText = 'position:fixed;top:0;left:0;pointer-events:none;z-index:9999999';
|
3
|
-
document.body.appendChild(canvasEl);
|
4
|
-
const ctx = canvasEl.getContext('2d');
|
5
|
-
const numberOfParticules = 30;
|
6
|
-
let pointerX = 0;
|
7
|
-
let pointerY = 0;
|
8
|
-
const tap = 'click';
|
9
|
-
const colors = CONFIG.fireworks;
|
10
|
-
function setCanvasSize() {
|
11
|
-
canvasEl.width = window.innerWidth * 2;
|
12
|
-
canvasEl.height = window.innerHeight * 2;
|
13
|
-
canvasEl.style.width = window.innerWidth + 'px';
|
14
|
-
canvasEl.style.height = window.innerHeight + 'px';
|
15
|
-
canvasEl.getContext('2d').scale(2, 2);
|
16
|
-
}
|
17
|
-
function updateCoords(e) {
|
18
|
-
pointerX = e.clientX || (e.touches && e.touches[0].clientX);
|
19
|
-
pointerY = e.clientY || (e.touches && e.touches[0].clientY);
|
20
|
-
}
|
21
|
-
function setParticuleDirection(p) {
|
22
|
-
const angle = anime.random(0, 360) * Math.PI / 180;
|
23
|
-
const value = anime.random(50, 180);
|
24
|
-
const radius = [-1, 1][anime.random(0, 1)] * value;
|
25
|
-
return {
|
26
|
-
x: p.x + radius * Math.cos(angle),
|
27
|
-
y: p.y + radius * Math.sin(angle)
|
28
|
-
};
|
29
|
-
}
|
30
|
-
function createParticule(x, y) {
|
31
|
-
const p = {
|
32
|
-
x: undefined,
|
33
|
-
y: undefined,
|
34
|
-
color: undefined,
|
35
|
-
radius: undefined,
|
36
|
-
endPos: undefined,
|
37
|
-
draw: undefined
|
38
|
-
};
|
39
|
-
p.x = x;
|
40
|
-
p.y = y;
|
41
|
-
p.color = colors[anime.random(0, colors.length - 1)];
|
42
|
-
p.radius = anime.random(16, 32);
|
43
|
-
p.endPos = setParticuleDirection(p);
|
44
|
-
p.draw = function () {
|
45
|
-
ctx.beginPath();
|
46
|
-
ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
|
47
|
-
ctx.fillStyle = p.color;
|
48
|
-
ctx.fill();
|
49
|
-
};
|
50
|
-
return p;
|
51
|
-
}
|
52
|
-
function createCircle(x, y) {
|
53
|
-
const p = {
|
54
|
-
x: undefined,
|
55
|
-
y: undefined,
|
56
|
-
color: undefined,
|
57
|
-
radius: undefined,
|
58
|
-
endPos: undefined,
|
59
|
-
alpha: undefined,
|
60
|
-
lineWidth: undefined,
|
61
|
-
draw: undefined
|
62
|
-
};
|
63
|
-
p.x = x;
|
64
|
-
p.y = y;
|
65
|
-
p.color = '#FFF';
|
66
|
-
p.radius = 0.1;
|
67
|
-
p.alpha = 0.5;
|
68
|
-
p.lineWidth = 6;
|
69
|
-
p.draw = function () {
|
70
|
-
ctx.globalAlpha = p.alpha;
|
71
|
-
ctx.beginPath();
|
72
|
-
ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
|
73
|
-
ctx.lineWidth = p.lineWidth;
|
74
|
-
ctx.strokeStyle = p.color;
|
75
|
-
ctx.stroke();
|
76
|
-
ctx.globalAlpha = 1;
|
77
|
-
};
|
78
|
-
return p;
|
79
|
-
}
|
80
|
-
function renderParticule(anim) {
|
81
|
-
for (let i = 0; i < anim.animatables.length; i++) {
|
82
|
-
anim.animatables[i].target.draw();
|
83
|
-
}
|
84
|
-
}
|
85
|
-
function animateParticules(x, y) {
|
86
|
-
const circle = createCircle(x, y);
|
87
|
-
const particules = [];
|
88
|
-
for (let i = 0; i < numberOfParticules; i++) {
|
89
|
-
particules.push(createParticule(x, y));
|
90
|
-
}
|
91
|
-
anime.timeline().add({
|
92
|
-
targets: particules,
|
93
|
-
x: function (p) {
|
94
|
-
return p.endPos.x;
|
95
|
-
},
|
96
|
-
y: function (p) {
|
97
|
-
return p.endPos.y;
|
98
|
-
},
|
99
|
-
radius: 0.1,
|
100
|
-
duration: anime.random(1200, 1800),
|
101
|
-
easing: 'easeOutExpo',
|
102
|
-
update: renderParticule
|
103
|
-
}).add({
|
104
|
-
targets: circle,
|
105
|
-
radius: anime.random(80, 160),
|
106
|
-
lineWidth: 0,
|
107
|
-
alpha: {
|
108
|
-
value: 0,
|
109
|
-
easing: 'linear',
|
110
|
-
duration: anime.random(600, 800)
|
111
|
-
},
|
112
|
-
duration: anime.random(1200, 1800),
|
113
|
-
easing: 'easeOutExpo',
|
114
|
-
update: renderParticule
|
115
|
-
}, 0);
|
116
|
-
}
|
117
|
-
const render = anime({
|
118
|
-
duration: Infinity,
|
119
|
-
update: function () {
|
120
|
-
ctx.clearRect(0, 0, canvasEl.width, canvasEl.height);
|
121
|
-
}
|
122
|
-
});
|
123
|
-
document.addEventListener(tap, function (e) {
|
124
|
-
render.play();
|
125
|
-
updateCoords(e);
|
126
|
-
animateParticules(pointerX, pointerY);
|
127
|
-
}, false);
|
128
|
-
setCanvasSize();
|
129
|
-
window.addEventListener('resize', setCanvasSize, false);
|
130
1
|
const sideBarToggleHandle = function (event, force) {
|
131
2
|
if (sideBar.hasClass('on')) {
|
132
3
|
sideBar.removeClass('on');
|
@@ -0,0 +1,129 @@
|
|
1
|
+
const canvasEl = document.createElement('canvas');
|
2
|
+
canvasEl.style.cssText = 'position:fixed;top:0;left:0;pointer-events:none;z-index:9999999';
|
3
|
+
document.body.appendChild(canvasEl);
|
4
|
+
const ctx = canvasEl.getContext('2d');
|
5
|
+
const numberOfParticules = 30;
|
6
|
+
let pointerX = 0;
|
7
|
+
let pointerY = 0;
|
8
|
+
const tap = 'click';
|
9
|
+
const colors = CONFIG.fireworks;
|
10
|
+
function setCanvasSize() {
|
11
|
+
canvasEl.width = window.innerWidth * 2;
|
12
|
+
canvasEl.height = window.innerHeight * 2;
|
13
|
+
canvasEl.style.width = window.innerWidth + 'px';
|
14
|
+
canvasEl.style.height = window.innerHeight + 'px';
|
15
|
+
canvasEl.getContext('2d').scale(2, 2);
|
16
|
+
}
|
17
|
+
function updateCoords(e) {
|
18
|
+
pointerX = e.clientX || (e.touches && e.touches[0].clientX);
|
19
|
+
pointerY = e.clientY || (e.touches && e.touches[0].clientY);
|
20
|
+
}
|
21
|
+
function setParticuleDirection(p) {
|
22
|
+
const angle = anime.random(0, 360) * Math.PI / 180;
|
23
|
+
const value = anime.random(50, 180);
|
24
|
+
const radius = [-1, 1][anime.random(0, 1)] * value;
|
25
|
+
return {
|
26
|
+
x: p.x + radius * Math.cos(angle),
|
27
|
+
y: p.y + radius * Math.sin(angle)
|
28
|
+
};
|
29
|
+
}
|
30
|
+
function createParticule(x, y) {
|
31
|
+
const p = {
|
32
|
+
x: undefined,
|
33
|
+
y: undefined,
|
34
|
+
color: undefined,
|
35
|
+
radius: undefined,
|
36
|
+
endPos: undefined,
|
37
|
+
draw: undefined
|
38
|
+
};
|
39
|
+
p.x = x;
|
40
|
+
p.y = y;
|
41
|
+
p.color = colors[anime.random(0, colors.length - 1)];
|
42
|
+
p.radius = anime.random(16, 32);
|
43
|
+
p.endPos = setParticuleDirection(p);
|
44
|
+
p.draw = function () {
|
45
|
+
ctx.beginPath();
|
46
|
+
ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
|
47
|
+
ctx.fillStyle = p.color;
|
48
|
+
ctx.fill();
|
49
|
+
};
|
50
|
+
return p;
|
51
|
+
}
|
52
|
+
function createCircle(x, y) {
|
53
|
+
const p = {
|
54
|
+
x: undefined,
|
55
|
+
y: undefined,
|
56
|
+
color: undefined,
|
57
|
+
radius: undefined,
|
58
|
+
endPos: undefined,
|
59
|
+
alpha: undefined,
|
60
|
+
lineWidth: undefined,
|
61
|
+
draw: undefined
|
62
|
+
};
|
63
|
+
p.x = x;
|
64
|
+
p.y = y;
|
65
|
+
p.color = '#FFF';
|
66
|
+
p.radius = 0.1;
|
67
|
+
p.alpha = 0.5;
|
68
|
+
p.lineWidth = 6;
|
69
|
+
p.draw = function () {
|
70
|
+
ctx.globalAlpha = p.alpha;
|
71
|
+
ctx.beginPath();
|
72
|
+
ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
|
73
|
+
ctx.lineWidth = p.lineWidth;
|
74
|
+
ctx.strokeStyle = p.color;
|
75
|
+
ctx.stroke();
|
76
|
+
ctx.globalAlpha = 1;
|
77
|
+
};
|
78
|
+
return p;
|
79
|
+
}
|
80
|
+
function renderParticule(anim) {
|
81
|
+
for (let i = 0; i < anim.animatables.length; i++) {
|
82
|
+
anim.animatables[i].target.draw();
|
83
|
+
}
|
84
|
+
}
|
85
|
+
function animateParticules(x, y) {
|
86
|
+
const circle = createCircle(x, y);
|
87
|
+
const particules = [];
|
88
|
+
for (let i = 0; i < numberOfParticules; i++) {
|
89
|
+
particules.push(createParticule(x, y));
|
90
|
+
}
|
91
|
+
anime.timeline().add({
|
92
|
+
targets: particules,
|
93
|
+
x: function (p) {
|
94
|
+
return p.endPos.x;
|
95
|
+
},
|
96
|
+
y: function (p) {
|
97
|
+
return p.endPos.y;
|
98
|
+
},
|
99
|
+
radius: 0.1,
|
100
|
+
duration: anime.random(1200, 1800),
|
101
|
+
easing: 'easeOutExpo',
|
102
|
+
update: renderParticule
|
103
|
+
}).add({
|
104
|
+
targets: circle,
|
105
|
+
radius: anime.random(80, 160),
|
106
|
+
lineWidth: 0,
|
107
|
+
alpha: {
|
108
|
+
value: 0,
|
109
|
+
easing: 'linear',
|
110
|
+
duration: anime.random(600, 800)
|
111
|
+
},
|
112
|
+
duration: anime.random(1200, 1800),
|
113
|
+
easing: 'easeOutExpo',
|
114
|
+
update: renderParticule
|
115
|
+
}, 0);
|
116
|
+
}
|
117
|
+
const render = anime({
|
118
|
+
duration: Infinity,
|
119
|
+
update: function () {
|
120
|
+
ctx.clearRect(0, 0, canvasEl.width, canvasEl.height);
|
121
|
+
}
|
122
|
+
});
|
123
|
+
document.addEventListener(tap, function (e) {
|
124
|
+
render.play();
|
125
|
+
updateCoords(e);
|
126
|
+
animateParticules(pointerX, pointerY);
|
127
|
+
}, false);
|
128
|
+
setCanvasSize();
|
129
|
+
window.addEventListener('resize', setCanvasSize, false);
|