erikwatson / snowfall.js

Stay cool ☃️
https://erikwatson.github.io/snowfall.js/
MIT License
4 stars 2 forks source link

Attach to custom elements #16

Closed erikwatson closed 2 months ago

erikwatson commented 3 years ago

Right now, Snowfall only attached to an element with the ID "snow-container". This isn't terrible, but it would be preferable to be able to attach it to whatever we want with a config property.

I'm not sure what it should feel like to use just yet, it seems easier on the user to pass a string to snowfall and let it find the element itself, like this.

snowfall.start({
  attachTo: '#customElement'
})

But perhaps it would be less of a headache if it instead expected to be passed exactly the element it should be attached to, more like this.

const container = document.querySelector('#customElement')

snowfall.start({
  attachTo: container
})

I am leaning towards the second version at the moment to avoid the headache of a user passing classes rather than IDs. Will have a think on it.

erikwatson commented 2 months ago

I've made this use the { attachTo: '#snowfall-container' } approach.