* 鼠标位置事件,根据鼠标的坐标将范围内的粒子连接起来
()
| 415 | * 鼠标位置事件,根据鼠标的坐标将范围内的粒子连接起来 |
| 416 | */ |
| 417 | private positionEvent(): void { |
| 418 | const { range } = this.options |
| 419 | |
| 420 | // 性能优化 |
| 421 | if (range > this.canvasWidth && range > this.canvasHeight) return |
| 422 | |
| 423 | this.eventProxy( |
| 424 | // 鼠标移动事件 |
| 425 | (left, top) => { |
| 426 | this.positionX = left |
| 427 | this.positionY = top |
| 428 | }, |
| 429 | // 陀螺仪事件 |
| 430 | (beta, gamma) => { |
| 431 | this.positionX = (-(gamma - 90) / 180) * this.canvasWidth |
| 432 | this.positionY = (-(beta - 90) / 180) * this.canvasHeight |
| 433 | } |
| 434 | ) |
| 435 | } |
| 436 | |
| 437 | /** |
| 438 | * 视差效果事件 |