Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
Easy Stretchy Nav
css
body { font-family: "proxima-nova", sans-serif; color: white; display: flex; height: 100vh; background: #111; overflow: hidden; flex-direction: column; justify-content: center; align-items: center; padding: 0; margin: 0; background: repeating-linear-gradient( 0deg, hsla(103, 11%, 32%, 0.09) 0px, hsla(103, 11%, 32%, 0.09) 1px, transparent 1px, transparent 11px ), repeating-linear-gradient( 90deg, hsla(103, 11%, 32%, 0.09) 0px, hsla(103, 11%, 32%, 0.09) 1px, transparent 1px, transparent 11px ), linear-gradient(90deg, hsl(317, 13%, 6%), hsl(317, 13%, 6%)); } #demo { width: 90vw; height: auto; max-width: 720px; overflow: visible; margin: 1rem auto; } #icons path { fill: white; } #stretchy { fill: #5da662; } text { font-weight: 700; font-size: 20px; text-transform: uppercase; fill: rgba(0, 0, 0, 0.5); } #icons g { cursor: pointer; } #icons rect { fill: transparent; stroke: rgba(255, 255, 255, 0.15); stroke-width: 2px; rx: 8px; ry: 8px; } h1, h2, p { margin: 0; } h2 { font-weight: 400; } h2 span { font-weight: 700; color: #5cceee; } a { background: #5cceee; color: white; padding: 10px; text-decoration: none; border-radius: 3px; margin-top: 10px; } a:hover { background: white; color: #5cceee; }
JavaScript
console.clear(); let targets = gsap.utils.toArray("#icons g"); let targetStarts = [20, 120, 220, 320, 420, 520]; let anim; let activeDot = 0; let targetDot; let maxDur = 0.6; targets.forEach((obj, i) => { obj.index = i; obj.addEventListener("click", letsStretch); }); function letsStretch() { targetDot = this.index; if (targetDot != activeDot) { if (anim && anim.isActive()) { anim.progress(1); } let oldX = targetStarts[activeDot]; let newX = targetStarts[targetDot]; let travel = Math.abs(oldX - newX); let factor = gsap.utils.mapRange(100, 500, 0.5, 1, travel); let dur = maxDur * factor; anim = gsap.timeline({ defaults: { duration: dur, ease: "back.in(2)" } }); if (newX > oldX) { anim.to("#stretchy", { attr: { width: travel + 60 } }); anim.to( "#stretchy", { attr: { x: newX, width: 60 }, ease: "back" }, "+=0.08" ); } else { anim.to("#stretchy", { attr: { x: newX, width: travel + 60 } }); anim.to("#stretchy", { attr: { width: 60 }, ease: "back" }, "+=0.08"); } anim.to( "#stretchy", { duration: dur, ease: "sine.inOut", attr: { height: 30, y: 45 }, yoyo: true, repeat: 1 }, 0 ); } else { return; } activeDot = targetDot; }
粒子
时间
文字
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号