1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 使用JS实现气泡跟随鼠标移动动画特效实例详解

使用JS实现气泡跟随鼠标移动动画特效实例详解

时间:2023-10-03 20:45:04

相关推荐

使用JS实现气泡跟随鼠标移动动画特效实例详解

web前端|js教程

javascript,鼠标,跟随

web前端-js教程

气泡跟随鼠标移动,并在每次点击时产生不同的变化,效果非常迷人,下面小编给大家带来了,基于js实现的气泡效果实例代码,需要的朋友参考下吧

iskyshop b2b2c源码,vscode开发php网站,ubuntu升级好久,部署iis需要tomcat,frontera爬虫,php 大于 小于,百度seo建设,c mvc网站源码下载,仿淘宝多用户商城 php 模板lzw

气泡跟随鼠标移动,并在每次点击时产生不同的变化

网络办公系统源码,vscode 运行快捷键,ubuntu用户锁定,帆软部署tomcat,重庆爬虫管,oracle 和php,潜江便宜的seo推广公司,评测网站 源码,苹果layui自适应模板lzw

效果如下

网页劫持源码,ubuntu环境规模复制,爬虫做种子搜索,wmi php,淄博seo 优化lzw

简单的气泡效果body{background-color:#000000;margin:0px;overflow:hidden}var canvas = document.createElement(canvas), context = canvas.getContext(2d), windowW = window.screen.width , windowH = window.screen.height , Mx, My, paused = true; suzu = []; booms = []; boomks = []; start(); canvas.onmousemove = function(e) { var loc = canvasMove(e.clientX, e.clientY); Mx = loc.x; My = loc.y }; canvas.onmousedown = function() { creatarry(Mx, My); paused = !paused }; function creatarry(a, b) { for (var i = 0; i 300) { boomks.shift() }; console.log(boomks) } }; function loop1() { boomks.forEach(function(circle) { context.beginPath(); context.arc(circle.x, circle.y, circle.radius, 0, Math.PI * 2, false); context.fillStyle = hsla( + circle.color + ,100%,60%, + circle.apc + ); context.fill(); movecircles(circle) }) } function movecircles(circle) { circle.x += circle.speedX; circle.speedY += circle.gravity; circle.y += circle.speedY; circle.apc -= 0.008 } function canvasMove(x, y) { var bbox = canvas.getBoundingClientRect(); return { x: x - bbox.left * (canvas.width / bbox.width), y: y - bbox.top * (canvas.height / bbox.height) } }; function start() { document.body.appendChild(canvas); canvas.width = windowW; canvas.height = windowH; setInterval(fang, 25) } function fang() { context.clearRect(0, 0, canvas.width, canvas.height); loop1(); loop() } function loop() { var circle = new createCircle(Mx, My); suzu.push(circle); for (i = 0; i 1000) { suzu.shift() } } function createCircle(x, y) { this.x = x; this.y = y; this.color = Math.random() * 360; this.radius = Math.random() * 25; this.xVel = Math.random() * 5 - 2; this.apc = 0.6; this.gravity = 0.07; this.yVel = Math.random() * 10 - 3; this.render = function(c) { c.beginPath(); c.arc(this.x, this.y, this.radius, 0, Math.PI * 2, true); c.fillStyle = hsla( + this.color + ,100%,60%, + this.apc + ); c.fill() }; this.update = function() { if (!paused) { this.yVel += this.gravity; this.y += this.yVel } else { this.y -= 5 } this.x += this.xVel; this.apc -= 0.01; if (this.radius > 1) { this.radius -= 0.4 } } }

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。