我gsap用来创建动画。
单击按钮时会创建气泡动画。
动画完成后会自行销毁。
我认为问题是使用 map 在React component但我找不到另一个案例
这是我的 React 代码和 js 小提琴示例:
https://jsfiddle.net/xiaowang/ueqsg83j/58/
const { useState, useEffect, useRef } = React;
gsap.registerPlugin(MotionPathPlugin)
const Bubble = ({ onClose, data }) => {
const pointRef = useRef(null)
useEffect(() => {
const path = []
let offsetY = 0
for(let i = 0; i < 10; i++) {
const y = offsetY - Math.floor(Math.random() * 20 + 30)
offsetY = y
path.push({ x: Math.floor(Math.random() * 40 - 20), y …Run Code Online (Sandbox Code Playgroud)