为了让动画更灵活并且简单 借助gsap让其具有更多可能,在未来更容易扩充其他动效 gsap Dom跟随鼠标移动 gsap.quickTo() 首先要监听鼠标移动,并且将移动的值转换到 -1 和 1 之间 方便处理 private mousemove(e: MouseEvent) { const x = (e.clientX / innerWidth); const y = (e.clientY / innerHeight); } 上面将 位置 / 屏幕宽高 将值缩放在 0 和 1之间 然后通过 乘2减1 将其限制在-1 和 1之间 private mousemove(e: MouseEvent) { const x = (e.clientX / innerWidth) * 2 - 1; const y = (e.clientY / innerHeight) * 2 - 1; } 在three中y轴 上面是1下面是-1 而我们窗口上面是-1 下面是1 所以取y轴剩余的高度让两者行为统一,也就是实现向着鼠标方向 private mousemove(e: MouseEvent) {...
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile