Make it possible to pass in a DOM Element instead of an id
See original GitHub issueIs your feature request related to a problem? Please describe. The current implementation requires you to add an id to a container or canvas, and pass that id when initialising tsparticles. Since most frameworks make it possible to get access to DOM references it would be nice if that was also supported.
This would allow frameworks like Svelte or Ember to implement a wrapper as an action or modifier respectively. (Other frameworks might have similar functionality.)
Describe the solution you’d like Make it possible to initialise tsparticles like this:
tsparticles.load(canvasOrContainerElement, options)
Describe alternatives you’ve considered Keep the current id string only api
Additional context
Potential Svelte wrapper api:
<div use:tsparticles={options}></div>
Potential Ember wrapper api:
<canvas {{tsparticles this.options}}></canvas>
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
React: Passing a DOM element instead of id to .play() method
I am trying to call the play() method: which takes an id of a node, searches it using document.getElementById() and executes the media ......
Read more >In JavaScript, can I just pass the id of an element as ... - Quora
If the former, then obviously yes. · If the latter, i.e. you mean a reference to an HTML element obtained via its id...
Read more >HTML DOM Element id Property - W3Schools
The id property sets or returns the value of an element's id attribute. Note. An id should be unique within a page. See...
Read more >How To Access Elements in the DOM - DigitalOcean
The easiest way to access a single element in the DOM is by its unique ID. You can get an element by ID...
Read more >class vs id - this vs that - in the front-end development?
If an element has the id attribute, we can access its DOM node from the global window object directly, such as window['the-id'] or...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Issue-Label Bot is automatically applying the label
feature_requestto this issue, with a confidence of 0.98. Please mark this comment with 👍 or 👎 to give our bot feedback!Links: app homepage, dashboard and code for this bot.
The
idis not linked by the Dom with thesetmethod, is used by tsParticles internally to retrieve same containers and avoid duplicates by destroying the old and create a new one. In theloadmethod theidis used to retrieve the DOM element and it’s set to the particles container too.