Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
body { height: 100vh; display: flex; align-items: center; justify-content: center; } svg { flex-shrink: 0; min-width: 600px; max-width: } #me { opacity: 0 }
JavaScript
window.ScrubGSAPTimeline = (tl) => { let mainTl = new TimelineLite(); if (Object.prototype.toString.call(tl) === '[object Array]') { let i = tl.length; while (--i > -1) { mainTl.add(tl[i], 0); } } else { mainTl = tl; } const Scrubber = (_tl) => { let mouseMove = (e) => { box.innerHTML = parseFloat(_tl.time()).toFixed(2); _tl.pause(); _tl.progress(e.clientX / (window.innerWidth)); // * tl.duration(); mouseX = e.clientX, mouseY = e.clientY; TweenLite.set(box, { x: (mouseX >= (window.innerWidth - 48)) ? mouseX - 48 : mouseX, y: (mouseY <= 20) ? mouseY + 20 : mouseY - 20 }) }, mouseOver = (e) => { _tl.pause(); _tl.play(0); TweenLite.set(box, { autoAlpha: 1 }) }, mouseOut = (e) => { _tl.play(e.clientX / (window.innerWidth) * _tl.duration()); TweenLite.set(box, { autoAlpha: 0 }) }, box = document.createElement('div'), mouseX, mouseY, gGreen = '#53A018', cssText = "position:fixed;border-radius:4px;font-size:14px;padding:5px;user-select:none;pointer-events:none;text-align:center;color:#53A018;top:0;left:0;font-family:Helvetica, Arial, sans-serif;background-color:#262626;line-height:1 !important;z-index:99999999" box.style.cssText = cssText; document.body.appendChild(box); document.body.onmousemove = mouseMove; document.body.onmouseover = mouseOver; document.body.onmouseout = mouseOut; document.body.ondblclick = (e) => { if (!document.body.onmousemove) { TweenLite.to(box, 0.2, { color: gGreen }) document.body.onmousemove = mouseMove; document.body.onmouseover = mouseOver; document.body.onmouseout = mouseOut; return; } TweenLite.to(box, 0.2, { color: '#A31632' }) document.body.onmousemove = null; document.body.onmouseover = null; document.body.onmouseout = null; _tl.pause(); } } Scrubber(mainTl); } const meTl = gsap.timeline({ onComplete: addMouseEvent, delay: 2, }); gsap.set('#bg', {transformOrigin: '50% 50%'}); gsap.set('#ear-right', {transformOrigin: '0% 50%'}); gsap.set('#ear-left', {transformOrigin: '100% 50%'}); gsap.set('#me', {opacity: 1}); meTl .from('#me', {duration: 1, yPercent: 100, ease: Elastic.easeOut.config(0.5, 0.4)}) .from( ['#head', '.hair', '.shadow'], {duration: 0.9, yPercent: 20, ease: Elastic.easeOut.config(0.58, 0.25)}, 0.1 ) .from( '#ear-right', {duration: 1, rotate: 40, yPercent: 10, ease: Elastic.easeOut.config(0.5, 0.2)}, 0.2 ) .from( '#ear-left', {duration: 1, rotate: -40, yPercent: 10, ease: Elastic.easeOut.config(0.5, 0.2)}, 0.2 ) .to( '#glasses', { duration: 1, keyframes: [{yPercent: -10}, {yPercent: -0}], ease: Elastic.easeOut.config(0.5, 0.2) }, 0.25 ) .from( ['#eyebrow-right', '#eyebrow-left'], {duration: 1, yPercent: 300, ease: Elastic.easeOut.config(0.5, 0.2)}, 0.2 ) .to(['#eye-right', '#eye-left'], {duration: 0.01, opacity: 1}, 0.35) .to(['#eye-right-2', '#eye-left-2'], {duration: 0.01, opacity: 0}, 0.35); // end animation // mouse coords let xPosition; let yPosition; let xPercent; let yPercent; let height; let width; function percentage(partialValue, totalValue) { return ((100 * partialValue) / totalValue).toFixed(2) * 1; } function updateWindowSize() { height = window.innerHeight; width = window.innerWidth; } updateWindowSize(); function updateScreenCoords(event) { if (event) { xPosition = event.clientX; yPosition = event.clientY; } } let storedXPosition = 0; let storedYPosition = 0; function animateFace() { if (xPosition) { // important, only recalculating if the value changes if (storedXPosition != xPosition && storedYPosition != yPosition) { console.log(xPosition, yPosition); xPercent = percentage(xPosition, width) - 50; yPercent = percentage(yPosition, height) - 20; yPercentLow = percentage(yPosition, height) - 80; yPercentHigh = percentage(yPosition, width) - 50; gsap.to('#face', {yPercent: yPercentLow / 30, xPercent: xPercent / 30}); gsap.to('.eye', {yPercent: yPercent / 3, xPercent: xPercent / 2}); gsap.to('#inner-face', {yPercent: yPercentHigh / 6, xPercent: xPercent / 8}); gsap.to('#hair-front', {yPercent: yPercent / 15, xPercent: xPercent / 22}); gsap.to(['#hair-back', '.shadow'], { yPercent: (yPercentLow / 20) * -1, xPercent: (xPercent / 20) * -1 }); gsap.to('.ear', { yPercent: (yPercentHigh / 1.5) * -1, xPercent: (xPercent / 10) * -1 }); gsap.to(['#eyebrow-left', '#eyebrow-right'], {yPercent: yPercentHigh * 2.5}); storedXPosition = xPosition; storedYPosition = yPosition; } } } const blink = gsap.timeline({repeat: -1, repeatDelay: 5, paused: true}); blink.to(['#eye-right', '#eye-left'], {duration: 0.01, opacity: 0}, 0); blink.to(['#eye-right-2', '#eye-left-2'], {duration: 0.01, opacity: 1}, 0); blink.to(['#eye-right', '#eye-left'], {duration: 0.01, opacity: 1}, 0.15); blink.to(['#eye-right-2', '#eye-left-2'], {duration: 0.01, opacity: 0}, 0.15); // function being called at the end of main timeline function addMouseEvent() { document.addEventListener('mousemove', updateScreenCoords); // gsap's RAF, falls back to set timeout gsap.ticker.add(animateFace); blink.play(); } window.addEventListener('resize', updateWindowSize);
粒子
时间
文字
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号