UNPKG

@tsparticles/interaction-external-repulse

Version:

tsParticles repulse external interaction

36 lines (35 loc) 1.14 kB
import { isNull, loadProperty } from "@tsparticles/engine"; export class RepulseBase { distance = 200; duration = 0.4; easing = "ease-out-quad"; factor = 100; maxSpeed = 50; restore; speed = 1; constructor() { this.restore = { enable: false, delay: 0, speed: 0.08, follow: true, }; } load(data) { if (isNull(data)) { return; } loadProperty(this, "distance", data.distance); loadProperty(this, "duration", data.duration); loadProperty(this, "easing", data.easing); loadProperty(this, "factor", data.factor); loadProperty(this, "speed", data.speed); loadProperty(this, "maxSpeed", data.maxSpeed); if (data.restore !== undefined) { this.restore.enable = data.restore.enable ?? this.restore.enable; this.restore.delay = data.restore.delay ?? this.restore.delay; this.restore.speed = data.restore.speed ?? this.restore.speed; this.restore.follow = data.restore.follow ?? this.restore.follow; } } }