Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
html, body { height: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } body { margin: 0; display: flex; align-items: center; justify-content: center; background: #1e313f; } button { width: 242px; border: 0; padding: 0; background: transparent; cursor: pointer; } .ear-left-outer, .ear-right-outer {fill:#919191;} .ear-left-inner, .ear-right-inner {fill:#6D6D6D;} .eye-right-outer, .eye-left-outer, .nostril-right-outer, .nostril-left-outer, .body {fill:#AAAAAA;} .eye-right-inner, .eye-left-inner {fill:#FFFFFF;} .nostril-right-inner, .nostril-left-inner{fill:#8C8C8C;} .freckle {fill:#7C7C7C;} .tongue {fill:#FF4848;} .tooth-left, .tooth-right {fill:#FFFFE1;} .link { font-family: 'Roboto', sans-serif; font-weight: 400; font-size: 13px; color: #ffffe3; text-decoration: none; position: absolute; bottom: 20px; right: 20px; border: 2px solid #335067; padding: 10px 14px; border-radius: 4px; transition: background 0.2s; } .link:hover { background: #243a4a; }
JavaScript
// -------------- // Hover animaton // -------------- const mouthSpeed = 0.3; const easeType = Power2.easeOut; const mouthOpen = gsap.timeline({ paused: true }); mouthOpen.to('.mouth-back', {duration: mouthSpeed, ease: easeType, y: -70}, 0); mouthOpen.to('.tongue', {duration: mouthSpeed * 1.5, ease: easeType, y: -70}, 0); mouthOpen.to('.teeth', {duration: mouthSpeed, ease: easeType, y: -70, scaleY: 1.2}, 0); mouthOpen.to('.body', {duration: mouthSpeed, ease: easeType, scaleY: 1.06, transformOrigin: 'center bottom'}, 0); mouthOpen.to('.freckles', {duration: mouthSpeed, ease: easeType, y: -10}, 0); mouthOpen.to('.ears', {duration: mouthSpeed, ease: easeType, y: 6}, 0); mouthOpen.to('.eye-right', {duration: mouthSpeed, ease: easeType, x: -2}, 0); mouthOpen.to('.eye-left', {duration: mouthSpeed, ease: easeType, x: 2}, 0); mouthOpen.to('.eyes', {duration: mouthSpeed, ease: easeType, y: 2}, 0); mouthOpen.to('.nostrils', {duration: mouthSpeed, ease: easeType, y: -6}, 0); // ------------ // Mouse events // ------------ const button = document.querySelector('button'); button.addEventListener('mouseenter', enterButton); button.addEventListener('mouseleave', leaveButton); function enterButton() { mouthOpen.play(); } function leaveButton() { mouthOpen.reverse(); } // ---------- // Ear wiggle // ---------- const earWiggle = gsap.timeline({ paused: true, repeat: 2 }); earWiggle.set('.ear-right', { transformOrigin: "center center" }); earWiggle.to('.ear-right', { duration: 0.1, rotation: 45 }); earWiggle.to('.ear-right', { duration: 0.1, rotation: 0 }); window.setInterval(earWigglePlay, 2500); function earWigglePlay() { earWiggle.play(0); } // ------------ // Eye tracking // ------------ const eyeRightPupil = document.querySelector('.eye-right-pupil'); const eyeLeftPupil = document.querySelector('.eye-left-pupil'); const eyeLeftInner = document.querySelector('.eye-left-inner'); const innerEyeWidth = eyeLeftInner.getBoundingClientRect().width; const innerEyeHeight = eyeLeftInner.getBoundingClientRect().height; const pupilWidth = eyeLeftPupil.getBoundingClientRect().width; const pupilHeight = eyeLeftPupil.getBoundingClientRect().height; const xMovement = (innerEyeWidth - pupilWidth)/2; const yMovement = (innerEyeHeight - pupilHeight)/2; window.addEventListener('mousemove', updateEyePosition); function updateEyePosition(event) { const posX = ((event.clientX / document.body.clientWidth) * 2 - 1) * xMovement; const posY = ((event.clientY / document.body.clientHeight) * 2 - 1) * yMovement; eyeLeftPupil.style.transform = `translate(${posX}px, ${posY}px)`; eyeRightPupil.style.transform = `translate(${posX}px, ${posY}px)`; }
粒子
时间
文字
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号