deblan.io-murph/assets/js/app/particles.js
2021-06-15 14:26:38 +02:00

47 lines
888 B
JavaScript

require('particles.js')
const Particles = function (w) {
this.window = w
}
Particles.prototype.start = function () {
if (this.window.innerWidth < 708) {
return
}
const height = this.header.offsetHeight
const width = this.header.offsetWidth - 40
let 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()
const that = this
this.window.addEventListener('resize', function () {
that.clean()
that.start()
}, false)
}
module.exports = Particles