【发布时间】:2020-09-13 02:44:14
【问题描述】:
我正在使用 react-spring 和 IntersectionObserver 为我的页面上的一些 div 元素设置动画。
对于IntersectionObserver,我使用的是教程here给出的钩子。
虽然我能够让 div 自行旋转 (onClick),并且 useIntersect 工作 - 我无法在 a 部分出现时触发旋转。我尝试过使用setState,就像我对onClick 所做的那样,但这不起作用,因为entry.isIntersecting 属性在每次重新渲染期间都会触发多次。
当达到 IntersectionObserver 阈值时,如何使用 react-spring 让 div 旋转?
【问题讨论】:
标签: javascript reactjs intersection-observer react-spring