前端动画:别再用 jQuery animate 了

前端动画:别再用 jQuery animate 了

毒舌时刻

这动画效果做得跟幻灯片似的,一点都不流畅。

各位前端同行,咱们今天聊聊前端动画。别告诉我你还在使用 jQuery animate,那感觉就像在没有减震器的情况下开车——能开,但颠簸得要命。

为什么你需要现代前端动画

最近看到一个项目,动画效果卡顿,代码复杂难以维护。我就想问:你是在做动画还是在做卡顿展示?

反面教材

// 反面教材:使用 jQuery animate // index.html <!DOCTYPE html> <html> <head> <title>jQuery Animation</title> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <style> .box { width: 100px; height: 100px; background-color: red; position: relative; } </style> </head> <body> <div></div> <button>动画</button> <script src="app.js"></script> </body> </html> // app.js $(document).ready(function() { $('#animate').click(function() { $('.box').animate({ left: '200px', opacity: '0.5', height: '200px', width: '200px' }, 1000); }); }); 

毒舌点评:这动画,就像在看幻灯片,一点都不流畅。

正确姿势

1. CSS 动画

/* 正确姿势:CSS 动画 */ /* styles.css */ .box { width: 100px; height: 100px; background-color: red; position: relative; transition: all 0.3s ease; } .box:hover { transform: scale(1.2); background-color: blue; } .box.animate { animation: move 1s ease forwards; } @keyframes move { from { left: 0; opacity: 1; height: 100px; width: 100px; } to { left: 200px; opacity: 0.5; height: 200px; width: 200px; } } /* index.html */ <!DOCTYPE html> <html> <head> <title>CSS Animation</title> <link rel="stylesheet" href="styles.css"> </head> <body> <div></div> <button>动画</button> <script src="app.js"></script> </body> </html> /* app.js */ document.getElementById('animate').addEventListener('click', function() { const box = document.querySelector('.box'); box.classList.add('animate'); setTimeout(() => { box.classList.remove('animate'); }, 1000); }); 

2. Framer Motion

// 正确姿势:Framer Motion // 1. 安装依赖 // npm install framer-motion // 2. 基本使用 import React, { useState } from 'react'; import { motion } from 'framer-motion'; function App() { const [animate, setAnimate] = useState(false); return ( <div> <motion.div className="box" initial={{ x: 0, opacity: 1, height: 100, width: 100 }} animate={animate ? { x: 200, opacity: 0.5, height: 200, width: 200 } : {}} transition={{ duration: 1 }} whileHover={{ scale: 1.1, backgroundColor: 'blue' }} /> <button onClick={() => setAnimate(!animate)}> {animate ? '重置' : '动画'} </button> </div> ); } export default App; // styles.css .box { background-color: red; position: relative; } 

3. GreenSock Animation Platform (GSAP)

// 正确姿势:GSAP // 1. 安装依赖 // npm install gsap // 2. 基本使用 import React, { useRef, useEffect } from 'react'; import gsap from 'gsap'; function App() { const boxRef = useRef(null); const handleAnimate = () => { gsap.to(boxRef.current, { x: 200, opacity: 0.5, height: 200, width: 200, duration: 1, ease: 'power2.out' }); }; const handleReset = () => { gsap.to(boxRef.current, { x: 0, opacity: 1, height: 100, width: 100, duration: 1, ease: 'power2.out' }); }; return ( <div> <div ref={boxRef} className="box"></div> <button onClick={handleAnimate}>动画</button> <button onClick={handleReset}>重置</button> </div> ); } export default App; // styles.css .box { width: 100px; height: 100px; background-color: red; position: relative; } 

4. React Spring

// 正确姿势:React Spring // 1. 安装依赖 // npm install @react-spring/web // 2. 基本使用 import React, { useState } from 'react'; import { useSpring, animated } from '@react-spring/web'; function App() { const [animate, setAnimate] = useState(false); const styles = useSpring({ x: animate ? 200 : 0, opacity: animate ? 0.5 : 1, height: animate ? 200 : 100, width: animate ? 200 : 100, config: { duration: 1000 } }); return ( <div> <animated.div className="box" style={styles} /> <button onClick={() => setAnimate(!animate)}> {animate ? '重置' : '动画'} </button> </div> ); } export default App; // styles.css .box { background-color: red; position: relative; } 

毒舌点评:这才叫现代前端动画,流畅自然,代码简洁,再也不用担心动画卡顿和维护困难了。

Read more

5分钟搭建第一个AI Agent:Claude Agent SDK实战指南

最近在折腾 Claude Agent SDK,忍不住想分享一下。 这东西真的太爽了。 一. 我为什么要折腾这个 说实话,我之前一直在用 Claude Code CLI,在终端里跟 AI 对话,让它帮我写代码、改 bug。 挺好用的,但有个问题。 每次都得手动打开终端,输入命令,等它跑完。我就想,能不能把这个能力嵌入到我自己的项目里? 比如做一个自动化运维工具,让 AI 自己去检查服务器状态、修复问题。 或者做一个代码审查机器人,每次提交代码自动帮我 review。 后来发现 Anthropic 出了个 Claude Agent SDK,就是把 Claude Code 的核心能力打包成了 Python 和 TypeScript 的库。 你可以用几行代码,就让

【AI大模型入门】02:豆包——字节出品,国内用户最顺手的AI助手

【AI大模型入门】02:豆包——字节出品,国内用户最顺手的AI助手

【AI大模型入门】02:豆包——字节出品,国内用户最顺手的AI助手 📖 阅读时长:约8分钟 🎯 适合人群:想找一个好用、免费、无障碍访问的AI工具的新手 💡 你将学到:豆包是什么、有哪些功能、和其他AI有什么区别、怎么快速上手 一、豆包是什么? 豆包(Doubao)是字节跳动(抖音、今日头条的母公司)推出的AI大模型产品,于2023年8月正式上线。 如果你用过抖音、今日头条,那你已经间接体验过字节AI技术的成果了。豆包就是字节把这些技术能力集中打包,做成了一个对话式AI助手。 字节跳动 AI 产品矩阵: ┌─────────────────────────────────┐ │ 豆包(对话助手) ←── 本篇主角 │ │ 即梦(图像/视频生成) │ │ 剪映AI(视频剪辑AI) │ │ 扣子(AI Agent搭建平台) │ └─────────────────────────────────┘ 二、为什么推荐新手先用豆包? 在所有AI产品里,我特别推荐国内新手从豆包开始,原因很简单: 优势说明✅

国产编程 AI 天花板来了!通义千问 Qwen3.6-Plus 深度测评:百万上下文 + 最强代码能力

📌 摘要 2026 年 4 月 2 日,阿里巴巴通义实验室正式发布新一代旗舰模型 Qwen3.6-Plus。这款模型以100 万 token 超长上下文、业界领先的 Agentic Coding 能力和原生多模态理解三大核心亮点,成为当下最值得关注的国产大模型。本文将从技术架构、核心能力、实测表现到使用指南,带你全面了解这款"编程最强国产 AI"。 一、重磅发布:Qwen3.6-Plus 是什么? Qwen3.6-Plus 是通义千问 Plus 系列的下一代进化版本,标志着阿里在通用人工智能领域的又一次重大突破。 与此前开源的 Qwen3 系列不同,Qwen3.6-Plus 采用专有模型策略(非开源),仅通过 API 提供服务。这是阿里从开源生态向商业化旗舰模型转型的重要信号,旨在为企业提供更稳定、

国内 AI 编程 Coding Plan 深度调研报告(2026年2月)

国内 AI 编程 Coding Plan 深度调研报告(2026年2月) 概述 2025年下半年至2026年初,国内多家 AI 大模型厂商密集推出面向开发者的 Coding Plan 编程订阅套餐,以固定月费替代按 Token 计费的模式,让开发者可以在 Claude Code、Cursor、Cline 等主流编程工具中使用国产大模型。目前主流平台包括火山方舟(字节跳动)、阿里云百炼、MiniMax、Kimi(月之暗面)、智谱 GLM 五大家,以及新兴的**无问芯穹(Infini)**聚合平台。本报告将从套餐定价、支持模型、真实可用额度、用户口碑、使用稳定性和方便性等维度进行全面对比分析。[^1] 六大平台快速对比 平台入门价首月特惠核心模型用量机制套餐档位核心亮点火山方舟¥40/月¥8.91豆包·DeepSeek·