deblan.io-murph/assets/js/app/particles.js

48 lines
949 B
JavaScript
Raw Normal View History

2021-06-15 14:26:38 +02:00
require('particles.js')
2021-03-29 19:40:55 +02:00
2022-09-08 10:26:58 +02:00
class Particles {
constructor(w) {
this.window = w
}
2022-09-08 10:26:58 +02:00
start() {
if (this.window.innerWidth < 708) {
return
}
2022-09-08 10:26:58 +02:00
const height = this.header.offsetHeight
const width = this.header.offsetWidth
2022-09-08 10:26:58 +02:00
this.particles.style.maxHeight = height + 'px'
this.particles.style.maxWidth = width + 'px'
2022-09-08 10:26:58 +02:00
particlesJS.load('particles', '/js/particles.json?v=3')
}
2022-09-08 10:26:58 +02:00
clean() {
this.particles.innerHTML = ''
}
2022-09-08 10:26:58 +02:00
init() {
this.particles = this.window.document.getElementById('particles')
2022-09-08 10:26:58 +02:00
if (!this.particles) {
return
}
2022-09-08 10:26:58 +02:00
this.header = this.particles.parentNode
2022-09-08 10:26:58 +02:00
this.clean()
this.start()
2022-09-08 10:26:58 +02:00
const that = this
2022-09-08 10:26:58 +02:00
this.window.addEventListener('resize', function() {
that.clean()
that.start()
}, false)
}
}
2022-09-09 09:40:25 +02:00
module.exports = Particles