Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
The mouth
css
body { background:#c9db36; font-family: Arial; color:linen; } #lips{stroke:#9dad29; fill:none;stroke-width:23;} #throat{fill:#7a160e;stroke:none;} #tongue{fill:#ee4f60} #_shadow,#__shadow{stroke:rgba(100,17,7,.1);stroke-width:23;fill:none;} #__shadow{stroke-width:30;stroke:rgba(0,0,0,.2);} #shadow1{ stroke:#c83650; stroke-width:20; stroke-linejoin:round; stroke-linecap:round; fill:none; } #shadow2{ stroke:#c83650; stroke-width:10; stroke-linecap:round;} #light{stroke:#fffbde;stroke-width:10;stroke-linecap:round; fill:none; stroke-dasharray:60, 20} circle{fill:#fffbde;} svg { width: 100vmin; position: absolute; margin: auto; top: 0; right: 0; bottom: 0; left: 0; } #track{fill:none;}
JavaScript
let rid = null; let trackLength = track.getTotalLength(); let m = {}; let draggable = false; let deltaX = 0; let spring = 0.3; let friction = 0.85; let vel = 0; let pos = trackLength / 2; let angle = 0; let base = track.getPointAtLength(pos); tongueSlider.setAttributeNS( null, "transform", "translate(" + base.x + "," + base.y + ")" ); function oMousePosSVG(e) { let p = svg.createSVGPoint(); p.x = e.clientX; p.y = e.clientY; let ctm = svg.getScreenCTM().inverse(); p = p.matrixTransform(ctm); return p; } tongueSlider.addEventListener("mousedown", function(e) { draggable = true; m = oMousePosSVG(e); let trans = parseFloat( tongueSlider .getAttribute("transform") .split("(")[1] .split(",")[0] ); deltaX = base.x + trans + 250 - m.x; //250 = 500/2 }); svg.addEventListener("mouseup", function() { draggable = false; if(rid){window.cancelAnimationFrame(rid); rid = null; angle=0;} Frame(); }); svg.addEventListener("mousemove", function(e) { if (pos > 466 || pos < 220) { draggable = false; if(rid){window.cancelAnimationFrame(rid); rid = null; angle=0;} Frame(); } if (draggable) { m = oMousePosSVG(e); pos = map(m.x + deltaX, 0, 500, 466, 220); angle = map(m.x + deltaX, 0, 500, 45, -45); let oPos = track.getPointAtLength(pos); tongueSlider.setAttributeNS( null, "transform", "translate(" + oPos.x + "," + oPos.y + ")" + "rotate(" + angle + ")" ); } }); svg.addEventListener("mouseleave", function(e) { draggable = false; if(rid){window.cancelAnimationFrame(rid); rid = null; angle=0;} Frame(); }); function map(n, a, b, _a, _b) { let d = b - a; let _d = _b - _a; let u = _d / d; return _a + n * u; } function updatePos(target) { let dist = target - pos; let acc = dist * spring; vel += acc; vel *= friction; pos += vel; } function updateAngle(target) { let dist = target - angle; let acc = dist * spring; vel += acc; vel *= friction; angle += vel; } function Frame() { rid = window.requestAnimationFrame(Frame); if (draggable == false) { let A = ~~pos; updatePos(trackLength / 2); let B = ~~pos; //console.log(A - B); updateAngle(0); if(A - B == 0){angle = 0;pos = trackLength / 2;} let oPos = track.getPointAtLength(pos); tongueSlider.setAttributeNS( null, "transform", "translate(" + oPos.x + "," + oPos.y + ")" + "rotate(" + angle + ")" ); if(A - B == 0){ window.cancelAnimationFrame(rid); rid = null;} } } //Frame();
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>SVG舌头-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号