Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
* { box-sizing: border-box; padding: 0; margin: 0; } /* center in the viewport */ body { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; background: hsl(240, 61%, 8%); } svg { display: block; width: 350px; height: auto; } /* CSS animation picked up by the slices */ @keyframes scale { to { transform: scale(1); } }
JavaScript
// function rendering the svg graphic on the basis of the values received from dat.gui function renderLoader(props) { const { paused, crispEdges, duration, initialScale, gap, innerRadius, number, } = props; document.querySelector('#root').innerHTML = `
${Array(number) .fill() .map( (item, index, { length }) => `
` ) .join('')}
`; } // dat.gui settings const ColorfulLoader = function() { // divide between the settings dedicated to the animation and those dedicated to the svg this.paused = false; this.duration = 1; this.initialScale = 0.5; this.crispEdges = false; this.gap = 2; this.innerRadius = 0; this.number = 10; // draw the svg with the default values renderLoader({ paused: this.paused, duration: this.duration, initialScale: this.initialScale, gap: this.gap, innerRadius: this.innerRadius, number: this.number, }); }; // function setting up dat.gui with the necessary controller // still getting to know the library window.onload = function() { const loader = new ColorfulLoader(); const gui = new dat.GUI(); // animation settings const f1 = gui.addFolder('Animation'); const togglePlayState = f1.add(loader, 'paused'); const updateDuration = f1.add(loader, 'duration', 0.5, 4); const updateInitialScale = f1.add(loader, 'initialScale', 0, 1); // toggle the animation-play-state property of all the group elements of class slice togglePlayState.onFinishChange(d => { const slices = document.querySelectorAll('.slice'); slices.forEach(slice => { slice.style.animationPlayState = d ? 'paused' : 'running'; }); }); // update the animation-duration _and_ animation-delay properties of the slices updateDuration.onFinishChange(d => { const slices = document.querySelectorAll('.slice'); slices.forEach((slice, index, { length }) => { slice.style.animationDuration = `${d}s`; slice.style.animationDelay = `${(d / length) * index * -1}s`; }); }); // set the initial transform value for the slices updateInitialScale.onFinishChange(d => { const slices = document.querySelectorAll('.slice'); slices.forEach(slice => { slice.style.transform = `scale(${d})`; }); }); // svg settings const f2 = gui.addFolder('Slices'); const toggleCrispEdges = f2.add(loader, 'crispEdges'); const updateGap = f2.add(loader, 'gap', 0, 10); const updateInnerRadius = f2.add(loader, 'innerRadius', 0, 48); const number = f2.add(loader, 'number', 2, 50).step(1); // toggle the shape-rendering property between crispEdges and auto toggleCrispEdges.onFinishChange(d => { const svg = document.querySelector('svg'); svg.setAttribute('shape-rendering', d ? 'crispEdges' : 'auto'); }); // update the stroke-width of the lines included in between the slices updateGap.onFinishChange(d => { const line = document.querySelector('#line'); line.setAttribute('stroke-width', d); }); // update the radius of the inner circle updateInnerRadius.onFinishChange(d => { const innerCircle = document.querySelector('#inner'); innerCircle.setAttribute('r', d); }); // re-render the entire svg graphic with the new number of slices number.onFinishChange(() => renderLoader(loader)); f1.open(); f2.open(); };
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>多彩加载动画-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号