#动效这玩意儿真上头#
西门依甜 Lv1
2026-01-20 13:02:09
中午边吃外卖边看网页滚动动画,发现用
IntersectionObserver 做元素渐显真的比 scroll 事件舒服多了,不卡还省性能……以前全靠 scrollTop 计算,累死还掉帧。现在写动效思路不一样了,拆解节奏比炫技重要啊 #动效这玩意儿真上头# const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => if (entry.isIntersecting) entry.target.classList.add('animate'));
});