hexo-theme-linen 1.0.29 → 1.0.30

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-linen",
3
- "version": "1.0.29",
3
+ "version": "1.0.30",
4
4
  "description": "A clean Hexo theme",
5
5
  "main": "index.js",
6
6
  "homepage": "https://github.com/lynanbreeze/hexo-theme-linen",
@@ -10,6 +10,8 @@
10
10
  }
11
11
  .nav-header.is-post {
12
12
  position: fixed;
13
+ transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
14
+ will-change: transform;
13
15
  }
14
16
  .nav-header.is-post.hide {
15
17
  transform: translateY(-100%);
@@ -239,8 +239,6 @@ body {
239
239
  background-color: #fff;
240
240
  // backdrop-filter: saturate(180%) blur(20px);
241
241
  transform: translateY(0);
242
- transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
243
- will-change: transform;
244
242
  z-index: 9;
245
243
  position: relative;
246
244
  top: 0;
@@ -369,7 +367,7 @@ body {
369
367
  }
370
368
  }
371
369
  &.hide {
372
- transform: translateY(-100%);
370
+ transform: translateY(0);
373
371
  }
374
372
  }
375
373
 
@@ -5,6 +5,7 @@ var isAnchoring = false;
5
5
  var anchoringId = null;
6
6
  var anchoringTimer = null;
7
7
  function triggerAnchoring() {
8
+ if (window.innerWidth > 1280) return;
8
9
  isAnchoring = true;
9
10
  var header = document.querySelector(".nav-header");
10
11
  if (header) {
@@ -13,6 +14,12 @@ function triggerAnchoring() {
13
14
  clearTimeout(anchoringTimer);
14
15
  anchoringTimer = setTimeout(function () {
15
16
  isAnchoring = false;
17
+ if (window.scrollY <= 60) {
18
+ var header = document.querySelector(".nav-header");
19
+ if (header) {
20
+ header.classList.remove("hide");
21
+ }
22
+ }
16
23
  }, 800);
17
24
  }
18
25
 
@@ -275,20 +282,28 @@ function onScroll() {
275
282
  typeof loadGitalk !== "undefined" && loadGitalk();
276
283
  }
277
284
 
278
- if (isAnchoring) {
279
- header.classList.add("hide");
280
- previousScrollY = currentScrollY;
281
- return;
285
+ var isMobilePost =
286
+ window.innerWidth <= 1280 && header.classList.contains("is-post");
287
+
288
+ // PC 端没有 header 隐藏逻辑,确保无 hide 类
289
+ if (!isMobilePost && header.classList.contains("hide")) {
290
+ header.classList.remove("hide");
282
291
  }
283
292
 
284
293
  // 接近顶部时(<= 60px),强制展开并退出,消除 iOS/Mac 橡皮筋回弹误判与闪烁
285
294
  if (currentScrollY <= 60) {
286
- header.classList.remove("hide");
295
+ if (isMobilePost) header.classList.remove("hide");
287
296
  if (backToTop) backToTop.classList.remove("visible");
288
297
  previousScrollY = currentScrollY;
289
298
  return;
290
299
  }
291
300
 
301
+ if (isMobilePost && isAnchoring) {
302
+ header.classList.add("hide");
303
+ previousScrollY = currentScrollY;
304
+ return;
305
+ }
306
+
292
307
  var scrollDelta = currentScrollY - previousScrollY;
293
308
  // 滤除手指微小抖动
294
309
  if (Math.abs(scrollDelta) < 8) {
@@ -297,7 +312,7 @@ function onScroll() {
297
312
 
298
313
  if (scrollDelta < 0) {
299
314
  // 向上滑动:即刻平滑展开导航栏
300
- if (!document.querySelector(".pswp--open")) {
315
+ if (isMobilePost && !document.querySelector(".pswp--open")) {
301
316
  header.classList.remove("hide");
302
317
  }
303
318
  if (backToTop && currentScrollY >= triggerHeight) {
@@ -306,7 +321,7 @@ function onScroll() {
306
321
  } else {
307
322
  // 向下滑动:离开顶部 60% 视口后平滑收起导航栏
308
323
  if (backToTop) backToTop.classList.remove("visible");
309
- if (currentScrollY > window.innerHeight * 0.6) {
324
+ if (isMobilePost && currentScrollY > window.innerHeight * 0.6) {
310
325
  header.classList.add("hide");
311
326
  }
312
327
  }
@@ -337,6 +352,11 @@ window.addEventListener("resize", function () {
337
352
  body.classList.add("resizing");
338
353
  viewportWidth = window.innerWidth;
339
354
 
355
+ if (window.innerWidth > 1280) {
356
+ const header = document.querySelector(".nav-header");
357
+ if (header) header.classList.remove("hide");
358
+ }
359
+
340
360
  clearTimeout(resizeTimer);
341
361
  resizeTimer = setTimeout(function () {
342
362
  body.classList.remove("resizing");
@@ -445,23 +465,46 @@ function handleClick(e) {
445
465
  maskElement.classList.remove("visible");
446
466
  setBodyScrollLocked(false);
447
467
  }
448
- if (targetId === "to-page-top") {
468
+ const firstTocLink = tocElement
469
+ ? tocElement.querySelector(".toc-item-link")
470
+ : null;
471
+ const isFirstToc =
472
+ target === firstTocLink ||
473
+ target.closest(".toc-item-link") === firstTocLink;
474
+
475
+ if (targetId === "to-page-top" || targetId === "page-top") {
449
476
  window.scrollTo({
450
477
  top: 0,
451
478
  left: 0,
452
479
  behavior: "instant",
453
480
  });
481
+ isAnchoring = false;
482
+ clearTimeout(anchoringTimer);
483
+ var header = document.querySelector(".nav-header");
484
+ if (header) {
485
+ header.classList.remove("hide");
486
+ }
454
487
  } else {
455
488
  anchor &&
456
489
  anchor.scrollIntoView({
457
490
  behavior: "instant",
458
491
  block: "start",
459
492
  });
460
- triggerAnchoring();
493
+ if (isFirstToc) {
494
+ isAnchoring = false;
495
+ clearTimeout(anchoringTimer);
496
+ var header = document.querySelector(".nav-header");
497
+ if (header) {
498
+ header.classList.remove("hide");
499
+ }
500
+ } else {
501
+ triggerAnchoring();
502
+ }
461
503
  }
462
504
  highlightAnchor(targetId);
463
505
  if (
464
506
  target.className?.includes("toc-item-link") &&
507
+ anchor &&
465
508
  isElementInViewport(anchor)
466
509
  ) {
467
510
  anchoringId = anchor.id;