MCPcopy Create free account
hub / github.com/Barrior/JParticles / positionEvent

Method positionEvent

src/particle.ts:417–435  ·  view source on GitHub ↗

* 鼠标位置事件,根据鼠标的坐标将范围内的粒子连接起来

()

Source from the content-addressed store, hash-verified

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 * 视差效果事件

Callers 1

initMethod · 0.95

Calls 1

eventProxyMethod · 0.95

Tested by

no test coverage detected