Files
aurora-admin/site/sources/carousel/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

56 lines
2.1 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 · Carousel(普通 H5)</title>
<link rel="stylesheet" href="../.design_library/aurora-admin/colors_and_type.css" />
<link rel="stylesheet" href="Carousel.css" />
<style>body{margin:0;padding:24px;background: var(--au-color-page-bg);}</style>
</head>
<body>
<div class="aa-carousel" id="app"></div>
<script>
var DATA = [
{ text: '促销活动一', color: '#2F54EB' },
{ text: '新品上市', color: '#13C2C2' },
{ text: '会员专享', color: '#722ED1' },
{ text: '限时秒杀', color: '#8C5A00' }
];
var index = 0, timer = null;
function render() {
var root = document.getElementById('app');
var slides = DATA.map(function (d) {
return '<div class="aa-carousel-slide" style="background:' + d.color + '">' + d.text + '</div>';
}).join('');
var dots = DATA.map(function (_, i) {
return '<span class="aa-carousel-dot ' + (i === index ? 'is-active' : '') + '" role="tab" tabindex="0" data-i="' + i + '"></span>';
}).join('');
root.innerHTML = '<div class="aa-carousel-track" style="transform:translateX(-' + (index * 100) + '%)">' + slides + '</div>' +
'<button class="aa-carousel-arrow prev">‹</button>' +
'<button class="aa-carousel-arrow next">›</button>' +
'<div class="aa-carousel-dots">' + dots + '</div>';
root.querySelector('.prev').onclick = function () { go(index - 1); };
root.querySelector('.next').onclick = function () { go(index + 1); };
root.querySelectorAll('.aa-carousel-dot').forEach(function (d) {
d.onclick = function () { go(parseInt(d.dataset.i, 10)); };
});
}
function go(i) {
index = (i + DATA.length) % DATA.length;
render();
restart();
}
function restart() {
if (timer) clearInterval(timer);
timer = setInterval(function () { go(index + 1); }, 3000);
}
render();
restart();
</script>
</body>
</html>