hexo-theme-hipaper-keyboarddaily 1.6.8 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_config.yml +7 -1
- package/layout/_partial/after-footer.ejs +2 -0
- package/layout/_partial/head.ejs +9 -0
- package/package.json +1 -1
- package/scripts/img-grid.js +60 -0
- package/source/css/img-grid.min.css +55 -0
- package/source/css/img-zoom.min.css +40 -0
- package/source/css/photoswipe.min.css +420 -0
- package/source/js/img-zoom.min.js +47 -0
- package/source/js/photoswipe-lightbox.esm.min.js +1960 -0
- package/source/js/photoswipe.esm.min.js +7081 -0
package/_config.yml
CHANGED
|
@@ -38,7 +38,13 @@ random_thumb: true
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
# Content
|
|
41
|
-
fancybox:
|
|
41
|
+
# fancybox: 主题自带的 jQuery Fancybox 2.x(只能放大,不能缩放/平移)
|
|
42
|
+
# photo_swipe: 内置的 PhotoSwipe 5 灯箱(支持缩放、平移、手势、多图切换)
|
|
43
|
+
# 两者互斥,同时为 true 时只生效 fancybox
|
|
44
|
+
fancybox: false
|
|
45
|
+
photo_swipe: true
|
|
46
|
+
# img_grid: 正文 {% imggrid %} 九宫格图片组样式(1 张单列、2/4 张两列、其余三列)
|
|
47
|
+
img_grid: true
|
|
42
48
|
|
|
43
49
|
|
|
44
50
|
# Sidebar
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
<% if (theme.fancybox){ %>
|
|
23
23
|
<%- css('fancybox/jquery.fancybox') %>
|
|
24
24
|
<%- js('fancybox/jquery.fancybox.pack') %>
|
|
25
|
+
<% } else if (theme.photo_swipe){ %>
|
|
26
|
+
<script type="module" src="<%- url_for('js/img-zoom.min.js') %>"></script>
|
|
25
27
|
<% } %>
|
|
26
28
|
|
|
27
29
|
<%- js('js/script') %>
|
package/layout/_partial/head.ejs
CHANGED
|
@@ -68,4 +68,13 @@
|
|
|
68
68
|
<link rel="stylesheet" href="<%- config.root %>css/fashion.css" >
|
|
69
69
|
<link rel="stylesheet" href="<%- config.root %>css/glyphs.css" >
|
|
70
70
|
|
|
71
|
+
<% if (theme.photo_swipe && !theme.fancybox){ %>
|
|
72
|
+
<%- css('css/photoswipe.min') %>
|
|
73
|
+
<%- css('css/img-zoom.min') %>
|
|
74
|
+
<% } %>
|
|
75
|
+
|
|
76
|
+
<% if (theme.img_grid){ %>
|
|
77
|
+
<%- css('css/img-grid.min') %>
|
|
78
|
+
<% } %>
|
|
79
|
+
|
|
71
80
|
</head>
|
package/package.json
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 九宫格图片组标签
|
|
3
|
+
*
|
|
4
|
+
* {% imggrid %}
|
|
5
|
+
* http://example.com/1.jpg
|
|
6
|
+
* http://example.com/2.jpg
|
|
7
|
+
* ...
|
|
8
|
+
* {% endimggrid %}
|
|
9
|
+
*
|
|
10
|
+
* 可选参数 contain:整组图片改为完整显示(不裁切),适合截图/长图。
|
|
11
|
+
* 列数由图片数量决定(见 css/img-grid.min.css):1 张单列、2/4 张两列、其余三列。
|
|
12
|
+
*/
|
|
13
|
+
hexo.extend.tag.register(
|
|
14
|
+
'imggrid',
|
|
15
|
+
function (args, content) {
|
|
16
|
+
var root = hexo.config.root || '/';
|
|
17
|
+
var contain = args.indexOf('contain') > -1;
|
|
18
|
+
|
|
19
|
+
var urls = String(content || '')
|
|
20
|
+
.split('\n')
|
|
21
|
+
.map(function (line) {
|
|
22
|
+
return line.trim();
|
|
23
|
+
})
|
|
24
|
+
.filter(function (line) {
|
|
25
|
+
return line && line.indexOf('#') !== 0;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (!urls.length) return '';
|
|
29
|
+
|
|
30
|
+
var escape = function (str) {
|
|
31
|
+
return str
|
|
32
|
+
.replace(/&/g, '&')
|
|
33
|
+
.replace(/"/g, '"')
|
|
34
|
+
.replace(/</g, '<')
|
|
35
|
+
.replace(/>/g, '>');
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
var items = urls
|
|
39
|
+
.map(function (url) {
|
|
40
|
+
var src = url;
|
|
41
|
+
if (!/^([a-z][a-z0-9+.-]*:)?\/\//i.test(src)) {
|
|
42
|
+
src = root + src.replace(/^\//, '');
|
|
43
|
+
}
|
|
44
|
+
src = escape(src);
|
|
45
|
+
return '<a class="fancybox" href="' + src + '"><img src="' + src + '" alt=""></a>';
|
|
46
|
+
})
|
|
47
|
+
.join('');
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
'<div class="img-grid" data-count="' +
|
|
51
|
+
urls.length +
|
|
52
|
+
'"' +
|
|
53
|
+
(contain ? ' data-fit="contain"' : '') +
|
|
54
|
+
'>' +
|
|
55
|
+
items +
|
|
56
|
+
'</div>'
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
{ ends: true }
|
|
60
|
+
);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* 微博九宫格图片组(配合 {% imggrid %} 标签使用)
|
|
2
|
+
列数按 data-count 决定:1 张单列不裁切、2/4 张两列、其余三列 */
|
|
3
|
+
.article-entry .img-grid {
|
|
4
|
+
display: grid;
|
|
5
|
+
grid-template-columns: repeat(3, 1fr);
|
|
6
|
+
gap: 4px;
|
|
7
|
+
margin: 1em 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.article-entry .img-grid[data-count="2"],
|
|
11
|
+
.article-entry .img-grid[data-count="4"] {
|
|
12
|
+
grid-template-columns: repeat(2, 1fr);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.article-entry .img-grid[data-count="1"] {
|
|
16
|
+
grid-template-columns: 1fr;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.article-entry .img-grid > a.fancybox {
|
|
20
|
+
display: block;
|
|
21
|
+
margin: 0;
|
|
22
|
+
aspect-ratio: 1 / 1;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
background: #f2f2f2;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.article-entry .img-grid img {
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: 100%;
|
|
30
|
+
object-fit: cover;
|
|
31
|
+
display: block;
|
|
32
|
+
margin: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* 单图与 contain 模式保留完整画面 */
|
|
36
|
+
.article-entry .img-grid[data-count="1"] > a.fancybox {
|
|
37
|
+
aspect-ratio: auto;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.article-entry .img-grid[data-count="1"] img,
|
|
41
|
+
.article-entry .img-grid[data-fit="contain"] img {
|
|
42
|
+
height: auto;
|
|
43
|
+
object-fit: contain;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* 主题脚本按 alt 插入的 .caption 会破坏格子对齐 */
|
|
47
|
+
.article-entry .img-grid .caption {
|
|
48
|
+
display: none;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@media (max-width: 600px) {
|
|
52
|
+
.article-entry .img-grid {
|
|
53
|
+
gap: 2px;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* 一行多图:md 里整行写
|
|
2
|
+
<div class="img-row"><img src="a.jpg"><img src="b.jpg"></div>
|
|
3
|
+
主题会把每张 img 包成 <a class="fancybox">,所以 <a> 才是 flex 项 */
|
|
4
|
+
.article-entry .img-row {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-wrap: wrap;
|
|
7
|
+
align-items: flex-start;
|
|
8
|
+
gap: 4px;
|
|
9
|
+
margin: 1em 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.article-entry .img-row > a.fancybox {
|
|
13
|
+
flex: 1 1 0;
|
|
14
|
+
min-width: 0;
|
|
15
|
+
margin: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.article-entry .img-row img {
|
|
19
|
+
width: 100%;
|
|
20
|
+
height: auto;
|
|
21
|
+
margin: 0;
|
|
22
|
+
display: block;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* 主题按 alt 插入的 .caption 会把行内图片顶开 */
|
|
26
|
+
.article-entry .img-row .caption {
|
|
27
|
+
display: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* 窄屏最多两列,三张及以上自动换行 */
|
|
31
|
+
@media (max-width: 600px) {
|
|
32
|
+
.article-entry .img-row > a.fancybox {
|
|
33
|
+
min-width: calc(50% - 2px);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* 可点击放大 */
|
|
38
|
+
.article-entry a.fancybox img {
|
|
39
|
+
cursor: zoom-in;
|
|
40
|
+
}
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
/*! PhotoSwipe main CSS by Dmytro Semenov | photoswipe.com */
|
|
2
|
+
|
|
3
|
+
.pswp {
|
|
4
|
+
--pswp-bg: #000;
|
|
5
|
+
--pswp-placeholder-bg: #222;
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
--pswp-root-z-index: 100000;
|
|
9
|
+
|
|
10
|
+
--pswp-preloader-color: rgba(79, 79, 79, 0.4);
|
|
11
|
+
--pswp-preloader-color-secondary: rgba(255, 255, 255, 0.9);
|
|
12
|
+
|
|
13
|
+
/* defined via js:
|
|
14
|
+
--pswp-transition-duration: 333ms; */
|
|
15
|
+
|
|
16
|
+
--pswp-icon-color: #fff;
|
|
17
|
+
--pswp-icon-color-secondary: #4f4f4f;
|
|
18
|
+
--pswp-icon-stroke-color: #4f4f4f;
|
|
19
|
+
--pswp-icon-stroke-width: 2px;
|
|
20
|
+
|
|
21
|
+
--pswp-error-text-color: var(--pswp-icon-color);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
Styles for basic PhotoSwipe (pswp) functionality (sliding area, open/close transitions)
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
.pswp {
|
|
30
|
+
position: fixed;
|
|
31
|
+
top: 0;
|
|
32
|
+
left: 0;
|
|
33
|
+
width: 100%;
|
|
34
|
+
height: 100%;
|
|
35
|
+
z-index: var(--pswp-root-z-index);
|
|
36
|
+
display: none;
|
|
37
|
+
touch-action: none;
|
|
38
|
+
outline: 0;
|
|
39
|
+
opacity: 0.003;
|
|
40
|
+
contain: layout style size;
|
|
41
|
+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* Prevents focus outline on the root element,
|
|
45
|
+
(it may be focused initially) */
|
|
46
|
+
.pswp:focus {
|
|
47
|
+
outline: 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.pswp * {
|
|
51
|
+
box-sizing: border-box;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.pswp img {
|
|
55
|
+
max-width: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.pswp--open {
|
|
59
|
+
display: block;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.pswp,
|
|
63
|
+
.pswp__bg {
|
|
64
|
+
transform: translateZ(0);
|
|
65
|
+
will-change: opacity;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.pswp__bg {
|
|
69
|
+
opacity: 0.005;
|
|
70
|
+
background: var(--pswp-bg);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.pswp,
|
|
74
|
+
.pswp__scroll-wrap {
|
|
75
|
+
overflow: hidden;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.pswp__scroll-wrap,
|
|
79
|
+
.pswp__bg,
|
|
80
|
+
.pswp__container,
|
|
81
|
+
.pswp__item,
|
|
82
|
+
.pswp__content,
|
|
83
|
+
.pswp__img,
|
|
84
|
+
.pswp__zoom-wrap {
|
|
85
|
+
position: absolute;
|
|
86
|
+
top: 0;
|
|
87
|
+
left: 0;
|
|
88
|
+
width: 100%;
|
|
89
|
+
height: 100%;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.pswp__img,
|
|
93
|
+
.pswp__zoom-wrap {
|
|
94
|
+
width: auto;
|
|
95
|
+
height: auto;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.pswp--click-to-zoom.pswp--zoom-allowed .pswp__img {
|
|
99
|
+
cursor: -webkit-zoom-in;
|
|
100
|
+
cursor: -moz-zoom-in;
|
|
101
|
+
cursor: zoom-in;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.pswp--click-to-zoom.pswp--zoomed-in .pswp__img {
|
|
105
|
+
cursor: move;
|
|
106
|
+
cursor: -webkit-grab;
|
|
107
|
+
cursor: -moz-grab;
|
|
108
|
+
cursor: grab;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.pswp--click-to-zoom.pswp--zoomed-in .pswp__img:active {
|
|
112
|
+
cursor: -webkit-grabbing;
|
|
113
|
+
cursor: -moz-grabbing;
|
|
114
|
+
cursor: grabbing;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* :active to override grabbing cursor */
|
|
118
|
+
.pswp--no-mouse-drag.pswp--zoomed-in .pswp__img,
|
|
119
|
+
.pswp--no-mouse-drag.pswp--zoomed-in .pswp__img:active,
|
|
120
|
+
.pswp__img {
|
|
121
|
+
cursor: -webkit-zoom-out;
|
|
122
|
+
cursor: -moz-zoom-out;
|
|
123
|
+
cursor: zoom-out;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
/* Prevent selection and tap highlights */
|
|
128
|
+
.pswp__container,
|
|
129
|
+
.pswp__img,
|
|
130
|
+
.pswp__button,
|
|
131
|
+
.pswp__counter {
|
|
132
|
+
-webkit-user-select: none;
|
|
133
|
+
-moz-user-select: none;
|
|
134
|
+
-ms-user-select: none;
|
|
135
|
+
user-select: none;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.pswp__item {
|
|
139
|
+
/* z-index for fade transition */
|
|
140
|
+
z-index: 1;
|
|
141
|
+
overflow: hidden;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.pswp__hidden {
|
|
145
|
+
display: none !important;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* Allow to click through pswp__content element, but not its children */
|
|
149
|
+
.pswp__content {
|
|
150
|
+
pointer-events: none;
|
|
151
|
+
}
|
|
152
|
+
.pswp__content > * {
|
|
153
|
+
pointer-events: auto;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
/*
|
|
158
|
+
|
|
159
|
+
PhotoSwipe UI
|
|
160
|
+
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
/*
|
|
164
|
+
Error message appears when image is not loaded
|
|
165
|
+
(JS option errorMsg controls markup)
|
|
166
|
+
*/
|
|
167
|
+
.pswp__error-msg-container {
|
|
168
|
+
display: grid;
|
|
169
|
+
}
|
|
170
|
+
.pswp__error-msg {
|
|
171
|
+
margin: auto;
|
|
172
|
+
font-size: 1em;
|
|
173
|
+
line-height: 1;
|
|
174
|
+
color: var(--pswp-error-text-color);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/*
|
|
178
|
+
class pswp__hide-on-close is applied to elements that
|
|
179
|
+
should hide (for example fade out) when PhotoSwipe is closed
|
|
180
|
+
and show (for example fade in) when PhotoSwipe is opened
|
|
181
|
+
*/
|
|
182
|
+
.pswp .pswp__hide-on-close {
|
|
183
|
+
opacity: 0.005;
|
|
184
|
+
will-change: opacity;
|
|
185
|
+
transition: opacity var(--pswp-transition-duration) cubic-bezier(0.4, 0, 0.22, 1);
|
|
186
|
+
z-index: 10; /* always overlap slide content */
|
|
187
|
+
pointer-events: none; /* hidden elements should not be clickable */
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/* class pswp--ui-visible is added when opening or closing transition starts */
|
|
191
|
+
.pswp--ui-visible .pswp__hide-on-close {
|
|
192
|
+
opacity: 1;
|
|
193
|
+
pointer-events: auto;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/* <button> styles, including css reset */
|
|
197
|
+
.pswp__button {
|
|
198
|
+
position: relative;
|
|
199
|
+
display: block;
|
|
200
|
+
width: 50px;
|
|
201
|
+
height: 60px;
|
|
202
|
+
padding: 0;
|
|
203
|
+
margin: 0;
|
|
204
|
+
overflow: hidden;
|
|
205
|
+
cursor: pointer;
|
|
206
|
+
background: none;
|
|
207
|
+
border: 0;
|
|
208
|
+
box-shadow: none;
|
|
209
|
+
opacity: 0.85;
|
|
210
|
+
-webkit-appearance: none;
|
|
211
|
+
-webkit-touch-callout: none;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.pswp__button:hover,
|
|
215
|
+
.pswp__button:active,
|
|
216
|
+
.pswp__button:focus {
|
|
217
|
+
transition: none;
|
|
218
|
+
padding: 0;
|
|
219
|
+
background: none;
|
|
220
|
+
border: 0;
|
|
221
|
+
box-shadow: none;
|
|
222
|
+
opacity: 1;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.pswp__button:disabled {
|
|
226
|
+
opacity: 0.3;
|
|
227
|
+
cursor: auto;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.pswp__icn {
|
|
231
|
+
fill: var(--pswp-icon-color);
|
|
232
|
+
color: var(--pswp-icon-color-secondary);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.pswp__icn {
|
|
236
|
+
position: absolute;
|
|
237
|
+
top: 14px;
|
|
238
|
+
left: 9px;
|
|
239
|
+
width: 32px;
|
|
240
|
+
height: 32px;
|
|
241
|
+
overflow: hidden;
|
|
242
|
+
pointer-events: none;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.pswp__icn-shadow {
|
|
246
|
+
stroke: var(--pswp-icon-stroke-color);
|
|
247
|
+
stroke-width: var(--pswp-icon-stroke-width);
|
|
248
|
+
fill: none;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.pswp__icn:focus {
|
|
252
|
+
outline: 0;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/*
|
|
256
|
+
div element that matches size of large image,
|
|
257
|
+
large image loads on top of it,
|
|
258
|
+
used when msrc is not provided
|
|
259
|
+
*/
|
|
260
|
+
div.pswp__img--placeholder,
|
|
261
|
+
.pswp__img--with-bg {
|
|
262
|
+
background: var(--pswp-placeholder-bg);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.pswp__top-bar {
|
|
266
|
+
position: absolute;
|
|
267
|
+
left: 0;
|
|
268
|
+
top: 0;
|
|
269
|
+
width: 100%;
|
|
270
|
+
height: 60px;
|
|
271
|
+
display: flex;
|
|
272
|
+
flex-direction: row;
|
|
273
|
+
justify-content: flex-end;
|
|
274
|
+
z-index: 10;
|
|
275
|
+
|
|
276
|
+
/* allow events to pass through top bar itself */
|
|
277
|
+
pointer-events: none !important;
|
|
278
|
+
}
|
|
279
|
+
.pswp__top-bar > * {
|
|
280
|
+
pointer-events: auto;
|
|
281
|
+
/* this makes transition significantly more smooth,
|
|
282
|
+
even though inner elements are not animated */
|
|
283
|
+
will-change: opacity;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
/*
|
|
288
|
+
|
|
289
|
+
Close button
|
|
290
|
+
|
|
291
|
+
*/
|
|
292
|
+
.pswp__button--close {
|
|
293
|
+
margin-right: 6px;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
/*
|
|
298
|
+
|
|
299
|
+
Arrow buttons
|
|
300
|
+
|
|
301
|
+
*/
|
|
302
|
+
.pswp__button--arrow {
|
|
303
|
+
position: absolute;
|
|
304
|
+
top: 0;
|
|
305
|
+
width: 75px;
|
|
306
|
+
height: 100px;
|
|
307
|
+
top: 50%;
|
|
308
|
+
margin-top: -50px;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.pswp__button--arrow:disabled {
|
|
312
|
+
display: none;
|
|
313
|
+
cursor: default;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.pswp__button--arrow .pswp__icn {
|
|
317
|
+
top: 50%;
|
|
318
|
+
margin-top: -30px;
|
|
319
|
+
width: 60px;
|
|
320
|
+
height: 60px;
|
|
321
|
+
background: none;
|
|
322
|
+
border-radius: 0;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.pswp--one-slide .pswp__button--arrow {
|
|
326
|
+
display: none;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/* hide arrows on touch screens */
|
|
330
|
+
.pswp--touch .pswp__button--arrow {
|
|
331
|
+
visibility: hidden;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/* show arrows only after mouse was used */
|
|
335
|
+
.pswp--has_mouse .pswp__button--arrow {
|
|
336
|
+
visibility: visible;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.pswp__button--arrow--prev {
|
|
340
|
+
right: auto;
|
|
341
|
+
left: 0px;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.pswp__button--arrow--next {
|
|
345
|
+
right: 0px;
|
|
346
|
+
}
|
|
347
|
+
.pswp__button--arrow--next .pswp__icn {
|
|
348
|
+
left: auto;
|
|
349
|
+
right: 14px;
|
|
350
|
+
/* flip horizontally */
|
|
351
|
+
transform: scale(-1, 1);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/*
|
|
355
|
+
|
|
356
|
+
Zoom button
|
|
357
|
+
|
|
358
|
+
*/
|
|
359
|
+
.pswp__button--zoom {
|
|
360
|
+
display: none;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.pswp--zoom-allowed .pswp__button--zoom {
|
|
364
|
+
display: block;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/* "+" => "-" */
|
|
368
|
+
.pswp--zoomed-in .pswp__zoom-icn-bar-v {
|
|
369
|
+
display: none;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
/*
|
|
374
|
+
|
|
375
|
+
Loading indicator
|
|
376
|
+
|
|
377
|
+
*/
|
|
378
|
+
.pswp__preloader {
|
|
379
|
+
position: relative;
|
|
380
|
+
overflow: hidden;
|
|
381
|
+
width: 50px;
|
|
382
|
+
height: 60px;
|
|
383
|
+
margin-right: auto;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.pswp__preloader .pswp__icn {
|
|
387
|
+
opacity: 0;
|
|
388
|
+
transition: opacity 0.2s linear;
|
|
389
|
+
animation: pswp-clockwise 600ms linear infinite;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.pswp__preloader--active .pswp__icn {
|
|
393
|
+
opacity: 0.85;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
@keyframes pswp-clockwise {
|
|
397
|
+
0% { transform: rotate(0deg); }
|
|
398
|
+
100% { transform: rotate(360deg); }
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
/*
|
|
403
|
+
|
|
404
|
+
"1 of 10" counter
|
|
405
|
+
|
|
406
|
+
*/
|
|
407
|
+
.pswp__counter {
|
|
408
|
+
height: 30px;
|
|
409
|
+
margin-top: 15px;
|
|
410
|
+
margin-inline-start: 20px;
|
|
411
|
+
font-size: 14px;
|
|
412
|
+
line-height: 30px;
|
|
413
|
+
color: var(--pswp-icon-color);
|
|
414
|
+
text-shadow: 1px 1px 3px var(--pswp-icon-color-secondary);
|
|
415
|
+
opacity: 0.85;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
.pswp--one-slide .pswp__counter {
|
|
419
|
+
display: none;
|
|
420
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// 主题内置图片灯箱(PhotoSwipe 5,已 vendored 到 source/js,不依赖 CDN)
|
|
2
|
+
// 由 _config.yml 的 photo_swipe 开关控制,需同时把 fancybox 置为 false(否则两套放大同时触发)。
|
|
3
|
+
// script.js 会把 .article-entry 内的每张 img 包成 <a class="fancybox" href="原图">,
|
|
4
|
+
// 这里直接以这些 <a> 作为灯箱条目;宽高在点击时从 img 的实际尺寸补齐(PhotoSwipe 必需)。
|
|
5
|
+
// 文件名以 .min.js 结尾是为了命中站点 hexo-neat 的排除规则(uglify-js 不认 ESM 语法),内容未压缩。
|
|
6
|
+
import PhotoSwipeLightbox from './photoswipe-lightbox.esm.min.js'
|
|
7
|
+
|
|
8
|
+
const options = {
|
|
9
|
+
pswpModule: () => import('./photoswipe.esm.min.js'),
|
|
10
|
+
bgOpacity: 0.9,
|
|
11
|
+
showHideAnimationType: 'zoom',
|
|
12
|
+
initialZoomLevel: 'fit',
|
|
13
|
+
secondaryZoomLevel: 1.5,
|
|
14
|
+
maxZoomLevel: 3,
|
|
15
|
+
wheelToZoom: true
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// 首页每篇文章的封面 <a class="article-gallery-img fancybox" href="文章地址"> 也在 .article-entry 里,
|
|
19
|
+
// 必须排除,否则点封面就打不开文章了。
|
|
20
|
+
const content = new PhotoSwipeLightbox({
|
|
21
|
+
...options,
|
|
22
|
+
gallery: '.article-entry',
|
|
23
|
+
children: 'a.fancybox:not(.article-gallery-img)'
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
// 文章头部的 photos 相册(.article-gallery,位于 .article-entry 之外)
|
|
27
|
+
const gallery = new PhotoSwipeLightbox({
|
|
28
|
+
...options,
|
|
29
|
+
gallery: '.article-gallery',
|
|
30
|
+
children: 'a.fancybox'
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const fillSize = (itemData, element) => {
|
|
34
|
+
const img = element.querySelector('img')
|
|
35
|
+
if (img && img.naturalWidth) {
|
|
36
|
+
itemData.src = img.currentSrc || img.src
|
|
37
|
+
itemData.width = img.naturalWidth
|
|
38
|
+
itemData.height = img.naturalHeight
|
|
39
|
+
}
|
|
40
|
+
return itemData
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
content.addFilter('domItemData', fillSize)
|
|
44
|
+
gallery.addFilter('domItemData', fillSize)
|
|
45
|
+
|
|
46
|
+
content.init()
|
|
47
|
+
gallery.init()
|