react实现跟随鼠标移动带尾巴的模糊小圆点效果代码
代码语言:html
所属分类:其他
代码描述:react实现跟随鼠标移动带尾巴的模糊小圆点效果代码
代码标签: react 跟随 鼠标 移动 尾巴 模糊 小圆点
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { margin: 0; height: 100vh; overflow: hidden; background: #000; } .canvas { width: 100%; height: 100vh; filter: blur(20px); } </style> </head> <body translate="no"> <div id="root"></div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/babel.7.18.13.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react.production.18.2.0.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react-dom.production.18.2.0.js"></script> <script type="text/babel"> const { useEffect, useRef, useState} = window.React; const { render } = window.ReactDOM; const lerp = (a, b, c) => (1 - c) * a + c * b const Cursor = () => { const $canvas = useRef() const $ctx = useRef() const point = useRef({x: window.innerWidth * .5, y: window.innerHeight * .5}) const mouse = useRef({x: window.innerWidth * .5, y: window.innerHeight * .5}) const win = useRef({ x: window.innerWidth, y: window.innerHeight}) const handleResize = () => { if (!$canvas.current) return win.current.w = window.innerWidth win.current.h = window.innerHeight $canvas.current.width = win.current.w $canva.........完整代码请登录后点击上方下载按钮下载查看
网友评论0