Aurora Admin v1.2.0: 79 components x 5 ends, doc site, contracts batch 1, playground, regression, deploy ready
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<!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:#F5F7FA;}</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="aa-carousel" id="app"></div>
|
||||
|
||||
<script>
|
||||
var DATA = [
|
||||
{ text: '促销活动一', color: '#2F54EB' },
|
||||
{ text: '新品上市', color: '#13C2C2' },
|
||||
{ text: '会员专享', color: '#722ED1' },
|
||||
{ text: '限时秒杀', color: '#FA8C16' }
|
||||
];
|
||||
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' : '') + '" 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>
|
||||
Reference in New Issue
Block a user