@tsparticles/interaction-particles-attract
Version:
tsParticles attract particles interaction
36 lines (35 loc) • 883 B
JavaScript
import { isNull, setRangeValue, } from "@tsparticles/engine";
export class Attract {
distance;
enable;
rotate;
constructor() {
this.distance = 200;
this.enable = false;
this.rotate = {
x: 3000,
y: 3000,
};
}
load(data) {
if (isNull(data)) {
return;
}
if (data.distance !== undefined) {
this.distance = setRangeValue(data.distance);
}
if (data.enable !== undefined) {
this.enable = data.enable;
}
if (data.rotate) {
const rotateX = data.rotate.x;
if (rotateX !== undefined) {
this.rotate.x = rotateX;
}
const rotateY = data.rotate.y;
if (rotateY !== undefined) {
this.rotate.y = rotateY;
}
}
}
}