fix: 管理员编辑跳过邮箱校验 + 返回顶部 rAF 丝滑滚动 + admin.js 正则笔误 + 页面标题污染
- artalk.js: beforeSubmit 在编辑态跳过昵称/邮箱校验(管理员改评论不再被拦) - floating-tools.js: 返回顶部/去评论改 rAF + easeInOutCubic 自绘,原生 smooth 不可靠 - admin.js: 修 5 处 //s //n 正则笔误(整脚本 SyntaxError 致后台全灰),需 wrangler deploy - artalk.html: 显式传 pageTitle(不再读 document.title,PJAX 竞态致文章页标题被记成「留言」) - artalk.js: conf 缓存合并前剔除 pageKey/pageTitle/pageThumb,杜绝跨页串值
This commit is contained in:
1 parent
e8c991274a
commit
437cd339ad
4 files changed
+59
-10
No files matched your search
@@ -1,3 +1,29 @@
|
||||
// 自绘平滑滚动:浏览器原生 behavior:'smooth' 又快又硬(约 300ms 且不可调),
|
||||
// 还会被系统的「减少动态效果」降级成瞬移。用 rAF + easeInOutCubic 自绘,
|
||||
// 时长随距离自适应,滚动一旦被用户滚轮/触摸打断立即让位。
|
||||
window.smoothScrollTo = function(targetY, duration) {
|
||||
var startY = window.scrollY;
|
||||
var diff = targetY - startY;
|
||||
if (Math.abs(diff) < 2) return;
|
||||
// 短距离快、长距离慢一些,但都 clamp 在 420~950ms,保证观感一致
|
||||
var dur = duration || Math.min(950, Math.max(420, Math.abs(diff) * 0.38));
|
||||
if (window.__smoothScrollRAF) cancelAnimationFrame(window.__smoothScrollRAF);
|
||||
var t0 = null, canceled = false;
|
||||
var cancel = function() { canceled = true; };
|
||||
window.addEventListener('wheel', cancel, { once: true, passive: true });
|
||||
window.addEventListener('touchstart', cancel, { once: true, passive: true });
|
||||
var ease = function(t) { return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2; };
|
||||
var step = function(ts) {
|
||||
if (canceled) return;
|
||||
if (t0 === null) t0 = ts;
|
||||
var p = Math.min(1, (ts - t0) / dur);
|
||||
window.scrollTo(0, startY + diff * ease(p));
|
||||
if (p < 1) window.__smoothScrollRAF = requestAnimationFrame(step);
|
||||
else window.__smoothScrollRAF = null;
|
||||
};
|
||||
window.__smoothScrollRAF = requestAnimationFrame(step);
|
||||
};
|
||||
|
||||
window.refreshFloatingTools = function() {
|
||||
if (typeof window.initFloatingTools !== 'function') return;
|
||||
var delays = [0, 60, 180];
|
||||
@@ -105,7 +131,7 @@ window.initFloatingTools = function() {
|
||||
|
||||
backToTopButton.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
window.smoothScrollTo(0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -206,7 +232,7 @@ window.initFloatingTools = function() {
|
||||
var comments = document.getElementById('Comments') || document.querySelector('.artalk');
|
||||
if (comments) {
|
||||
var y = comments.getBoundingClientRect().top + window.scrollY - 20;
|
||||
window.scrollTo({ top: y, behavior: 'smooth' });
|
||||
window.smoothScrollTo(y);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user