48 lines
949 B
JavaScript
48 lines
949 B
JavaScript
require('particles.js')
|
|
|
|
class Particles {
|
|
constructor(w) {
|
|
this.window = w
|
|
}
|
|
|
|
start() {
|
|
if (this.window.innerWidth < 708) {
|
|
return
|
|
}
|
|
|
|
const height = this.header.offsetHeight
|
|
const width = this.header.offsetWidth
|
|
|
|
this.particles.style.maxHeight = height + 'px'
|
|
this.particles.style.maxWidth = width + 'px'
|
|
|
|
particlesJS.load('particles', '/js/particles.json?v=3')
|
|
}
|
|
|
|
clean() {
|
|
this.particles.innerHTML = ''
|
|
}
|
|
|
|
init() {
|
|
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
|