deblan.io-murph/assets/js/app/particles.js
2021-03-29 19:40:55 +02:00

47 lines
950 B
JavaScript

require('particles.js');
const Particles = function(w) {
this.window = w;
}
Particles.prototype.start = function() {
if (this.window.innerWidth < 708) {
return;
}
var height = this.header.offsetHeight;
var width = this.header.offsetWidth - 40;
var canvas;
this.particles.style.maxHeight = height + 'px';
this.particles.style.maxWidth = width + 'px';
particlesJS.load('particles', '/js/particles.json?v=3');
}
Particles.prototype.clean = function() {
this.particles.innerHTML = '';
}
Particles.prototype.init = function() {
this.particles = this.window.document.getElementById('particles');
if (!this.particles) {
return;
}
this.header = this.particles.parentNode;
this.clean();
this.start();
var that = this;
this.window.addEventListener('resize', function() {
that.clean();
that.start();
}, false);
}
module.exports = Particles