hexo-theme-volantis 6.0.4 → 6.0.5
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/source/js/app.js +27 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [6.0.5](https://github.com/volantis-x/hexo-theme-volantis/compare/v6.0.4...v6.0.5) (2026-07-08)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* 修复锚点定位 ([f589671](https://github.com/volantis-x/hexo-theme-volantis/commit/f58967153414817eafc59fceb48b60184f6f3dd9))
|
|
9
|
+
|
|
3
10
|
## [6.0.4](https://github.com/volantis-x/hexo-theme-volantis/compare/v6.0.3...v6.0.4) (2026-06-09)
|
|
4
11
|
|
|
5
12
|
|
package/package.json
CHANGED
package/source/js/app.js
CHANGED
|
@@ -33,14 +33,14 @@ const locationHash = () => {
|
|
|
33
33
|
if (target) {
|
|
34
34
|
setTimeout(() => {
|
|
35
35
|
if (window.location.hash.startsWith('#fn')) { // hexo-reference https://github.com/volantis-x/hexo-theme-volantis/issues/647
|
|
36
|
-
|
|
36
|
+
VolantisApp.scrolltoElement(target,VolantisApp.getScrollCorrection() - VolantisApp.REM, 'instant', true);
|
|
37
37
|
} else if (window.location.hash.startsWith('#mjx')) { // mathjax
|
|
38
|
-
|
|
38
|
+
VolantisApp.scrolltoElement(target,VolantisApp.getScrollCorrection() + VolantisApp.REM, 'instant', true);
|
|
39
39
|
} else {
|
|
40
|
-
// 锚点中上半部有大片空白 高度大概是 volantis.dom.header.offsetHeight
|
|
41
|
-
|
|
40
|
+
// 文章标题锚点 锚点中上半部有大片空白 高度大概是 volantis.dom.header.offsetHeight=64
|
|
41
|
+
VolantisApp.scrolltoElement(target,VolantisApp.REM, 'instant', true);
|
|
42
42
|
}
|
|
43
|
-
},
|
|
43
|
+
}, 500)
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -50,11 +50,12 @@ Object.freeze(locationHash);
|
|
|
50
50
|
const VolantisApp = (() => {
|
|
51
51
|
const fn = {},
|
|
52
52
|
COPYHTML = '<button class="btn-copy" data-clipboard-snippet=""><i class="fa-solid fa-copy"></i><span>COPY</span></button>';
|
|
53
|
+
const REM = parseFloat(getComputedStyle(document.documentElement).fontSize); // 16
|
|
53
54
|
let scrollCorrection = 80;
|
|
54
55
|
|
|
55
56
|
fn.init = () => {
|
|
56
57
|
if (volantis.dom.header) {
|
|
57
|
-
scrollCorrection = volantis.dom.header.clientHeight + 16
|
|
58
|
+
scrollCorrection = volantis.dom.header.clientHeight + REM; // 64+16
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
window.onresize = () => {
|
|
@@ -109,7 +110,7 @@ const VolantisApp = (() => {
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
fn.restData = () => {
|
|
112
|
-
scrollCorrection = volantis.dom.header ? volantis.dom.header.clientHeight +
|
|
113
|
+
scrollCorrection = volantis.dom.header ? volantis.dom.header.clientHeight + REM : 80;
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
fn.setIsMobile = () => {
|
|
@@ -123,10 +124,17 @@ const VolantisApp = (() => {
|
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
// 校正页面定位(被导航栏挡住的区域)
|
|
126
|
-
fn.scrolltoElement = (elem, correction = scrollCorrection) => {
|
|
127
|
-
|
|
127
|
+
fn.scrolltoElement = (elem, correction = scrollCorrection, behavior = null, observer = false) => {
|
|
128
|
+
let opt = {
|
|
128
129
|
top: elem.getBoundingClientRect().top + document.documentElement.scrollTop - correction
|
|
129
|
-
}
|
|
130
|
+
};
|
|
131
|
+
if (behavior){
|
|
132
|
+
opt.behavior=behavior;
|
|
133
|
+
};
|
|
134
|
+
if (observer){
|
|
135
|
+
opt.observer=observer;
|
|
136
|
+
};
|
|
137
|
+
volantis.scroll.to(elem, opt);
|
|
130
138
|
}
|
|
131
139
|
|
|
132
140
|
// 滚动事件回调们
|
|
@@ -399,7 +407,7 @@ const VolantisApp = (() => {
|
|
|
399
407
|
e.preventDefault();
|
|
400
408
|
let target = document.getElementById(targetID);
|
|
401
409
|
if (target) {
|
|
402
|
-
|
|
410
|
+
fn.scrolltoElement(target, scrollCorrection + REM, 'instant');
|
|
403
411
|
}
|
|
404
412
|
});
|
|
405
413
|
})
|
|
@@ -407,16 +415,16 @@ const VolantisApp = (() => {
|
|
|
407
415
|
|
|
408
416
|
// hexo-reference 页脚跳转 https://github.com/volantis-x/hexo-theme-volantis/issues/647
|
|
409
417
|
fn.footnotes = () => {
|
|
410
|
-
let ref = document.querySelectorAll('#l_main .footnote-backref, #l_main .footnote-ref > a');
|
|
418
|
+
let ref = document.querySelectorAll('#l_main a[rel=footnote],#footnotelist a[rev=footnote],#l_main .footnote-backref, #l_main .footnote-ref > a');
|
|
411
419
|
ref.forEach(function (e, i) {
|
|
412
420
|
ref[i].click = () => { }; // 强制清空原 click 事件
|
|
421
|
+
let targetID = decodeURIComponent(ref[i].getAttribute('href').split('#')[1]).replace(/\ /g, '-');
|
|
413
422
|
volantis.dom.$(e).on('click', (e) => {
|
|
414
423
|
e.stopPropagation();
|
|
415
424
|
e.preventDefault();
|
|
416
|
-
let targetID = decodeURI(e.target.hash.split('#')[1]).replace(/\ /g, '-');
|
|
417
425
|
let target = document.getElementById(targetID);
|
|
418
426
|
if (target) {
|
|
419
|
-
|
|
427
|
+
fn.scrolltoElement(target, scrollCorrection - REM, 'instant');
|
|
420
428
|
}
|
|
421
429
|
});
|
|
422
430
|
})
|
|
@@ -719,7 +727,11 @@ const VolantisApp = (() => {
|
|
|
719
727
|
question: fn.question,
|
|
720
728
|
hideMessage: fn.hideMessage,
|
|
721
729
|
messageCopyright: fn.messageCopyright,
|
|
722
|
-
scrolltoElement: fn.scrolltoElement
|
|
730
|
+
scrolltoElement: fn.scrolltoElement,
|
|
731
|
+
getScrollCorrection: ()=>{
|
|
732
|
+
return scrollCorrection;
|
|
733
|
+
},
|
|
734
|
+
REM:REM
|
|
723
735
|
}
|
|
724
736
|
})()
|
|
725
737
|
Object.freeze(VolantisApp);
|