前端动画:别再用 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

2026 最新 FPGA——学霸学习导图汇总

2026 最新 FPGA——学霸学习导图汇总

随着 FPGA 技术在 AI、通信、自动驾驶、5G/6G、大规模数据中心等领域的重要性持续攀升,越来越多同学希望系统掌握 FPGA 的核心技能。但面对浩繁的知识点和庞大的工具链,新手常常不知从何学起。 为此,这篇文章整理了 2026 年最新 FPGA 学习导图与学习路径总结,帮你从零打造 FPGA 学霸级路线图! 🔥 一、FPGA 学习总览 FPGA(Field Programmable Gate Array)是一种可重构硬件设备,它不像 MCU 那样运行软件,而是通过硬件电路本身实现逻辑功能。 一个完整的 FPGA 学习体系通常包括: 📌 基础理论 📌 HDL 编程(Verilog / VHDL / SystemVerilog) 📌 仿真 & 综合 & 时序分析

Ψ0——人形全身VLA:先用800h人类自视角视频数据和30h的真实机器人交互数据预训练VLM,再后训练MM-DiT,最后用AMO做下肢RL跟踪

Ψ0——人形全身VLA:先用800h人类自视角视频数据和30h的真实机器人交互数据预训练VLM,再后训练MM-DiT,最后用AMO做下肢RL跟踪

前言 今26年3.11,一投资人微信上跟我说,“ 周老师好!最近在搞什么模型?今天USC大学发布的这个模型,请您评估看看?” 我当时回复她道,“这个我这个星期,抽时间解读一下,到时候再说一下我的看法哦” 对于本文要解读的Ψ0 1. 首先,作者在大规模第一视角人类视频(约800 小时的人类视频数据),和30 小时的真实世界机器人数据上对一个 VLM 主干进行自回归预训练,以获得具有良好泛化能力的视觉-动作表征 2. 随后,再在高质量的人形机器人数据上后训练一个基于流(flow-based)的动作专家,用于学习精确的机器人关节控制 个人认为,该工作在理念创新上 确实 挺不错的 1. 以规模不大的“人类第一视角数据和真实机器人交互数据”预训练vlm 再后训练、微调 避免一味 堆数据,毕竟 数据 很难是个头 2. 全身摇操系统 看起来 也组合的不错 更重要的是,虽然目前市面上loco-mani方向的工作已经不少了

快速掌握PyMAVLink:无人机通信的Python实战指南

快速掌握PyMAVLink:无人机通信的Python实战指南 【免费下载链接】pymavlinkpython MAVLink interface and utilities 项目地址: https://gitcode.com/gh_mirrors/py/pymavlink 在当今无人机技术飞速发展的时代,PyMAVLink作为Python实现的MAVLink协议库,已经成为连接地面站与飞行器的关键桥梁。这个强大的工具库不仅简化了无人机通信的复杂性,更为开发者提供了完整的解决方案。 从零开始:PyMAVLink架构解析 核心通信层设计 PyMAVLink的核心架构围绕MAVLink协议栈构建,通过mavutil.py模块实现了与无人机的高效通信。该模块提供了多种连接方式,包括串口、TCP/UDP网络连接等,确保开发者能够灵活应对不同的应用场景。 协议版本支持:项目支持完整的MAVLink协议版本演进,从v0.9到v2.0,每个版本都有对应的dialects目录实现。这种分层架构确保了向后兼容性和协议扩展性。 多语言代码生成引擎 generator/mavgen.py是整

FPGA 工程师到底有哪些方向?每个岗位都在干什么?一篇给你讲清楚

FPGA 工程师到底有哪些方向?每个岗位都在干什么?一篇给你讲清楚

很多人说“学 FPGA 就是写 Verilog”,但真正进了行业才发现—— FPGA 工程师并不是一个岗位,而是一整个岗位族群。 不同公司、不同项目,对 FPGA 工程师的要求差异非常大。 如果方向选错,可能学了半年发现岗位根本不对口。 这篇文章就系统地给你拆一拆: 👉 FPGA 工程师到底有哪些岗位? 👉 每个岗位具体干什么? 👉 需要掌握哪些能力? 👉 适合什么样的人? 一、FPGA 工程师整体岗位划分(先给结论) 从企业招聘角度来看,FPGA 岗位大致可以分为 6 类: 岗位方向关键词偏向FPGA 逻辑设计工程师Verilog / 时序 / 接口核心开发FPGA 算法 / 加速工程师图像 / AI / DSP算法落地FPGA 底层驱动工程师DDR / PCIe / SerDes硬件接口FPGA 系统应用工程师Linux + FPGA系统集成FPGA 验证 / 测试仿真 / 验证质量保障FPGA 技术支持 / FA客户 / 项目支持应用型