hexo-theme-gnix 4.2.4 → 4.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-gnix",
3
- "version": "4.2.4",
3
+ "version": "4.2.5",
4
4
  "author": "Efterklang <gaojiaxing0220@gmail.com>",
5
5
  "license": "MIT",
6
6
  "description": "Second generation of Hexo theme Icarus, now with Catppuccin flavor and night mode support.",
package/source/js/pjax.js CHANGED
@@ -1,5 +1,4 @@
1
1
  (() => {
2
- // biome-ignore lint/correctness/noUnusedVariables: will be used
3
2
  let pjax;
4
3
 
5
4
  function initPjax() {
@@ -11,7 +10,7 @@
11
10
  });
12
11
 
13
12
  window.addEventListener("popstate", () => {
14
- if (pjax && pjax.loadUrl) {
13
+ if (pjax?.loadUrl) {
15
14
  pjax.loadUrl(window.location.href);
16
15
  }
17
16
  });
@@ -56,58 +56,29 @@ const FeatureHandlers = {
56
56
  expandCode(figure) {
57
57
  const expandBtn = figure.querySelector(SELECTORS.expandBtn);
58
58
  const pre = figure.querySelector(SELECTORS.preShiki);
59
-
60
59
  const isExpanded = figure.classList.contains("expanded");
61
60
  const showLines = parseInt(figure.dataset.showLines || "10", 10);
62
61
 
63
62
  if (isExpanded) {
64
- // 记录折叠前的状态
65
- const beforeCollapseHeight = pre.scrollHeight;
66
-
67
- // 计算折叠后的目标高度
68
63
  const computedStyle = getComputedStyle(pre);
69
64
  const lineHeight = parseFloat(computedStyle.lineHeight) || 20;
70
65
  const paddingTop = parseFloat(computedStyle.paddingTop) || 0;
71
66
  const paddingBottom = parseFloat(computedStyle.paddingBottom) || 0;
72
67
  const targetHeight = showLines * lineHeight + paddingTop + paddingBottom;
73
68
 
74
- // 首先设置当前完整高度作为起点
75
- pre.style.maxHeight = `${beforeCollapseHeight}px`;
76
-
77
- // 应用折叠状态
78
- requestAnimationFrame(() => {
79
- figure.classList.remove("expanded");
80
- pre.style.maxHeight = `${targetHeight}px`;
81
-
82
- // 延迟箭头旋转,等待折叠动画完成
83
- setTimeout(() => {
84
- expandBtn.classList.remove(CLASSES.expandDone);
85
- }, 300); // 与CSS transition时间同步
86
- });
69
+ figure.classList.remove("expanded");
70
+ pre.style.maxHeight = `${targetHeight}px`;
71
+ expandBtn.classList.remove(CLASSES.expandDone);
87
72
  } else {
88
- // 展开代码
89
- const currentHeight = pre.offsetHeight;
90
73
  const fullHeight = pre.scrollHeight;
91
74
 
92
- // 先设置当前高度作为起点
93
- pre.style.maxHeight = `${currentHeight}px`;
94
-
95
- // 应用展开状态
96
75
  figure.classList.add("expanded");
76
+ pre.style.maxHeight = `${fullHeight}px`;
77
+ expandBtn.classList.add(CLASSES.expandDone);
97
78
 
98
- requestAnimationFrame(() => {
99
- pre.style.maxHeight = `${fullHeight}px`;
100
-
101
- // 立即开始箭头旋转动画
102
- expandBtn.classList.add(CLASSES.expandDone);
103
-
104
- // 动画结束后清除max-height限制,允许内容自然增长
105
- setTimeout(() => {
106
- if (figure.classList.contains("expanded")) {
107
- pre.style.maxHeight = "none";
108
- }
109
- }, 300);
110
- });
79
+ setTimeout(() => {
80
+ pre.style.maxHeight = "none";
81
+ }, 300);
111
82
  }
112
83
  },
113
84
  };
@@ -117,7 +88,7 @@ function handleToolbarClick(event) {
117
88
  const classList = target.classList;
118
89
 
119
90
  const handlers = {
120
- expand: () => FeatureHandlers.shrink(this),
91
+ "expand": () => FeatureHandlers.expandCode(this),
121
92
  "copy-button": () => FeatureHandlers.copy(this, target),
122
93
  "toggle-wrap": () => FeatureHandlers.toggleWrap(this),
123
94
  };