Files
aurora-admin/site/sources/backtotop/html.txt
T
aurora-admin c65a69c34e
Deploy to GitHub Pages / deploy (push) Failing after 16s
Regression / regression (push) Failing after 15m2s
feat(P4): precompute移植+app.js sources双向回填+回归1003/1003+验收体积/文件/data.json
2026-09-12 14:18:41 +08:00

54 lines
2.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Aurora Admin · BackToTop(普通 H5)</title>
<link rel="stylesheet" href="../.design_library/aurora-admin/colors_and_type.css" />
<link rel="stylesheet" href="BackToTop.css" />
<style>
body { margin: 0; background: var(--au-color-page-bg); font-family: var(--font-family, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif); }
.aa-demo-banner { padding: 24px; background: var(--au-color-card-bg); border-bottom: 1px solid var(--au-color-border); }
.aa-demo-banner h2 { margin: 0 0 8px; color: var(--au-color-text-title); font-size: 18px; }
.aa-demo-banner p { margin: 0; color: var(--au-color-text-secondary); font-size: 13px; }
.aa-demo-spacer { height: 2200px; padding: 24px; color: var(--au-color-text-secondary); }
</style>
</head>
<body>
<div class="aa-demo-banner">
<h2>向下滚动页面</h2>
<p>滚动超过 400px 后右下角出现返回顶部按钮,环显示滚动进度,点击平滑回到顶部。</p>
</div>
<div class="aa-demo-spacer">这里是长内容占位区……</div>
<div class="aa-backtop" id="backtop" role="button" aria-label="返回顶部">
<svg viewBox="0 0 44 44">
<circle class="aa-backtop-ring-bg" aria-label="返回顶部" cx="22" cy="22" r="20" fill="none" stroke-width="2" />
<circle class="aa-backtop-ring-fg" role="button" aria-label="返回顶部" id="ring" cx="22" cy="22" r="20" fill="none" stroke-width="2" />
</svg>
<span class="aa-backtop-arrow" aria-label="返回顶部">↑</span>
</div>
<script>
var THRESHOLD = 400, R = 20, C = 2 * Math.PI * R;
var el = document.getElementById('backtop');
var ring = document.getElementById('ring');
ring.style.strokeDasharray = C;
ring.style.strokeDashoffset = C;
function onScroll() {
var st = window.pageYOffset || document.documentElement.scrollTop;
var max = document.documentElement.scrollHeight - window.innerHeight;
var p = max > 0 ? st / max : 0;
el.classList.toggle('is-visible', st > THRESHOLD);
ring.style.strokeDashoffset = C * (1 - p);
}
window.addEventListener('scroll', onScroll, { passive: true });
el.addEventListener('click', function () {
window.scrollTo({ top: 0, behavior: 'smooth' });
});
onScroll();
</script>
</body>
</html>