File size: 831 Bytes
15bfa8d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import './index.scss'

export interface VoiceProps extends CSSPropertyRule {
  num?: number;
  duration?: number;
}
export default function Voice({ duration = 400, num = 7, ...others }) {
  return (
    <div className="voice-button" { ...others }>
      {Array.from({ length: num }).map((_, index) => {
        const randomDuration = Math.random() * 100 + duration
        const initialDelay = Math.random() * 2 * duration
        const initialScale = Math.sin((index + 1) * Math.PI / num)
        return (
          <div
            className="voice-button-item"
            key={index}
            style={{
              animationDelay: initialDelay + 'ms',
              animationDuration: randomDuration + 'ms',
              transform: `scale(${initialScale})`
            }}
          />
        )
      })}
    </div>
  )
}