forked from CarrotSkin/carrotskin
Merge branch 'main' of https://code.littlelan.cn/uNagi/carrotskin
This commit is contained in:
@@ -23,11 +23,9 @@ export default function Home() {
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
// 添加防抖处理,减少状态更新频率
|
||||
let timeoutId: number | undefined;
|
||||
|
||||
const handleMouseMove = (e: MouseEvent) => {
|
||||
// 使用防抖,每16ms更新一次(约60fps)
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = window.setTimeout(() => {
|
||||
setMousePosition({ x: e.clientX, y: e.clientY });
|
||||
@@ -87,7 +85,6 @@ export default function Home() {
|
||||
<div
|
||||
className="absolute w-32 h-32 bg-gradient-to-r from-orange-400/30 to-amber-400/30 rounded-full blur-2xl transition-all duration-150 ease-out will-change-transform"
|
||||
style={{
|
||||
// 使用transform而非top/left,利用GPU加速
|
||||
transform: `translate(${mousePosition.x - 64}px, ${mousePosition.y - 64}px) scale(${isHovered ? 1.5 : 1})`
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user